Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion movement/look_rotation/example/look_rotation.script
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ local function quat_look_rotation(forward, upwards)
return vmath.quat()
end

-- Handle alignment with up direction
if math.abs(vmath.dot(forward, upwards)) > 0.9999999 then
return vmath.quat_from_to(vmath.vector3(0, 0, 1), forward)
end

-- Create a rotation matrix from the forward and upwards vectors
local matrix = vmath.matrix4_look_at(vmath.vector3(0), forward, upwards)

Expand Down Expand Up @@ -61,4 +66,4 @@ function on_input(self, action_id, action)
if action.pressed then
next_target(self)
end
end
end