![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | FellowGamedev |
var MOUSE_SENSITIVITY = 0.005
var rot_x = 0
var rot_x_target = 0
var rot_y = 0
var rot_y_target = 0
var rot_z = 0
var rot_z_target = 0
func _process(delta):
transform.basis = Basis()
rot_x_target = lerp(rot_x_target,rot_x,0.05)
rot_y_target = lerp(rot_y_target,rot_y,0.05)
rot_z_target = lerp(rot_z_target,rot_z,0.05)
rotate_object_local(Vector3(0, 1, 0), rot_x_target)
rotate_object_local(Vector3(1, 0, 0), rot_y_target)
if Input.is_key_pressed(KEY_E):
rot_z -= .01
if Input.is_key_pressed(KEY_Q):
rot_z += .01
rotate_object_local(Vector3(0, 0, 1), rot_z_target)
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event):
if event is InputEventMouseMotion:
rot_x -= (event.relative.x * MOUSE_SENSITIVITY )
rot_y -= (event.relative.y * MOUSE_SENSITIVITY )
everything is working as intended until I press Q or E which results in the object rotating along the Z axis(as intended) but the issue here is that if I rotate along the X and Y axis they don’t rotate along the new Z axis.
you can slap this code on a camera node and see for yourself what I mean
any help would be very much appreciated!