Skip to content

Commit 81d4934

Browse files
authored
Handle alignment with up direction in the Look Rotation example (#91)
* Handle alignment with up direction in look_rotation.script * Update look rotation alignment threshold
1 parent 549a2a8 commit 81d4934

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

movement/look_rotation/example/look_rotation.script

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ local function quat_look_rotation(forward, upwards)
1111
return vmath.quat()
1212
end
1313

14+
-- Handle alignment with up direction
15+
if math.abs(vmath.dot(forward, upwards)) > 0.9999999 then
16+
return vmath.quat_from_to(vmath.vector3(0, 0, 1), forward)
17+
end
18+
1419
-- Create a rotation matrix from the forward and upwards vectors
1520
local matrix = vmath.matrix4_look_at(vmath.vector3(0), forward, upwards)
1621

@@ -61,4 +66,4 @@ function on_input(self, action_id, action)
6166
if action_id == hash("mouse_button_left") and action.pressed then
6267
next_target(self)
6368
end
64-
end
69+
end

0 commit comments

Comments
 (0)