- Edited
I am making a game where you can control a fast moving rocket using the mouse (like you look around in an fps)
func _physics_process(delta : float) -> void:
position += transform.basis * Vector3(0, 0, -SPEED) * delta #constantly move in the pointing direction
func _unhandled_input(event : InputEvent) -> void:
if event is InputEventMouseMotion:
rotate_y(-event.relative.x * SENSITIVITY) #rotate vertically according to mouse movement
rotate_x(-event.relative.y * SENSITIVITY) #rotate horizontally according to mouse movement
transform = transform.orthonormalized()
The problem is after a couple of seconds the controls don't behave normally, and the doesn't rotate normally.
I read about this issue in the docs regarding rotation, which is why I added transform.orthonormalized()
but it doesn't solve the issue.
Should I do the rotating inside _process ?
I am bad at Vector math and rotations, so can anybody point me in the right direction ?
(I can post a video of the weird behaviour if it helps)