class_name CameraGimbal extends Node3D @export var rotation_speed = (PI / 180) * 120 func reset(): basis = Basis() $InnerGimbal.basis = Basis() func rotate_camera_y(y, delta): rotate_object_local(Vector3.UP, y * rotation_speed * delta) func rotate_camera_x(x, delta): $InnerGimbal.rotate_object_local( Vector3.RIGHT, x * rotation_speed * delta) func _process(delta): # rotate outer gimbal around y axis var y = 0 if Input.is_action_pressed("cam_left"): y += 1 if Input.is_action_pressed("cam_right"): y -= 1 rotate_camera_y(y, delta) # rotate inner gimbal around x axis var x = 0 if Input.is_action_pressed("cam_up"): x -= 1 if Input.is_action_pressed("cam_down"): x += 1 rotate_camera_x(x, delta) # reset gimbals if Input.is_action_pressed("cam_reset"): reset()