You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Babushka/scripts/GdScript/camera_pivot.gd

25 lines
741 B

extends Node3D
# DEPRECATED, please use C# version
@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)