Files

25 lines
741 B
GDScript
Raw Permalink Normal View History

2024-12-02 18:50:26 +01:00
extends Node3D
2025-03-26 00:26:29 +01:00
# DEPRECATED, please use C# version
2024-12-02 18:50:26 +01:00
@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)