extends Node3D @export var canPitch: bool = false @export var canYaw: bool = false @export var rotateSpeed: float = 0.003 @onready var sub_pivot: Node3D = $SubPivot func _ready() -> void: Input.mouse_mode = Input.MOUSE_MODE_CAPTURED func _input(event): if event.is_action_pressed("click"): if Input.mouse_mode == Input.MOUSE_MODE_VISIBLE: Input.mouse_mode = Input.MOUSE_MODE_CAPTURED if event.is_action_pressed("ui_cancel"): Input.mouse_mode = Input.MOUSE_MODE_VISIBLE if event is InputEventMouseMotion: if Input.mouse_mode != Input.MOUSE_MODE_CAPTURED: return if canYaw: sub_pivot.rotate_x(event.relative.y * -rotateSpeed) if canPitch: rotate_y(event.relative.x * -rotateSpeed)