Hi,
i'm trying to write a movement script for a spaceship/mech and struggling to come up with something that works. Every existing solution I've come across seems to suffer from the same problem: when you rotate your view vertically (around the X axis), the local y-axis transform (sorry if I'm misusing the terminology, new to this) doesn't follow and any subsequent horizontal rotation, unless you reset your vertical rotation, occurs on 2 axes at once. essentially i need any mouse input to be relative only to the current view direction, since there's no gravity/ground/absolute direction. i thought it was gimbal lock when i was first using transforms so i tried to adapt a quaternion solution someone posted (code below) which didn't change anything. also tried to make a hybrid that does a local transform rotation but failed miserably, does any1 have any advice on how to accomplish this? i do not really understand quaternions. thank you kindly
func _input(event):
if event is InputEventMouseMotion and Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
var mouse_delta = -event.relative * MOUSE_SENSITIVITY
var threshold = .00001
var delta_y_max = (-transform.basis.z).angle_to(Vector3.UP * sign(mouse_delta.y) )
mouse_delta.y = clamp(abs(mouse_delta.y), 0.0, delta_y_max - threshold) * sign(mouse_delta.y)
var horz_quat = Quat(transform.basis.xform_inv(Vector3.UP), mouse_delta.x)
var vert_quat = Quat(Vector3.RIGHT, mouse_delta.y)
transform.basis *= Basis(horz_quat * vert_quat)
transform.basis = transform.basis.orthonormalized()