extends Node3D
var sensitivity = 0.005
var camera_pitch = 0.0

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)


# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
	pass

func _unhandled_input(event: InputEvent) -> void:
	if event is InputEventMouseMotion:
		$"..".rotate_y(-event.relative.x * sensitivity)
		
		camera_pitch -= event.relative.y * sensitivity
		camera_pitch = clamp(camera_pitch, deg_to_rad(-90), deg_to_rad(90))
		$".".rotation.x = camera_pitch
		
	if event.is_action_pressed("ui_cancel"):
		Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
