Godot Version
Godot 4.4.1 Stable
Question
Hello!
I’ve come across this code in the manual for First Person Camera Movement using Transforms.
# accumulators
var rot_x = 0
var rot_y = 0
func _input(event):
if event is InputEventMouseMotion and event.button_mask & 1:
# modify accumulated mouse rotation
rot_x += event.relative.x * LOOKAROUND_SPEED
rot_y += event.relative.y * LOOKAROUND_SPEED
transform.basis = Basis() # reset rotation
rotate_object_local(Vector3(0, 1, 0), rot_x) # first rotate in Y
rotate_object_local(Vector3(1, 0, 0), rot_y) # then rotate in X
From my current understanding, rotate_object_local(Vector3(0, 1, 0), rot_x) and rotate_y(rot_x) should be equivalent. However, replacing rotate_object_local(Vector3(0, 1, 0), rot_x) with rotate_y(rot_x) and rotate_object_local(Vector3(1, 0, 0), rot_y) with rotate_x(rot_y) results in different behavior of the camera: It starts tilting when moving diagonally.
For my test scene, I just have a simple, untransformed camera at world origin.
Why would this change not result in the same behavior?