#in variables before functions @export var camera : Node3D var current_pitch:float = 0.0 var current_yaw:float = 0.0 @export var common_mouse_sensitivity:float = 0.09 var mouse_sens_x:float = common_mouse_sensitivity var mouse_sens_y:float = common_mouse_sensitivity #below func _input(event:InputEvent) -> void: if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED: var mouse_motion_event: InputEventMouseMotion = event as InputEventMouseMotion var yaw_delta: float = mouse_motion_event.relative.x * mouse_sens_x var pitch_delta: float = mouse_motion_event.relative.y * mouse_sens_y sway_mouse_input = Vector2(-yaw_delta,-pitch_delta) current_yaw_func(yaw_delta) current_pitch_func(pitch_delta) func current_yaw_func(yaw_delta: float) -> void: current_yaw = wrapf(current_yaw + yaw_delta, -360.0, 360.0) basis = Basis() rotate_object_local(Vector3.DOWN, deg_to_rad(current_yaw)) orthonormalize() func current_pitch_func(pitch_delta: float) -> void: current_pitch = wrapf(current_pitch + pitch_delta, -360.0, 360.0) current_pitch = clampf(current_pitch, -90.0, 90.0) camera.basis = Basis() camera.rotate_object_local(Vector3.LEFT, deg_to_rad(current_pitch)) orthonormalize()
or share this direct link: