26 lines
563 B
GDScript
26 lines
563 B
GDScript
extends Camera3D
|
|
|
|
@export var mouse_sensitivity := 0.003
|
|
|
|
var rotation_x: float
|
|
var rotation_y: float
|
|
|
|
|
|
func _ready():
|
|
# Запоминаем начальное положение камеры
|
|
rotation_x = rotation.x
|
|
rotation_y = rotation.y
|
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
|
|
|
|
|
func _input(event):
|
|
if event is InputEventMouseMotion:
|
|
rotation_y -= event.relative.x * mouse_sensitivity
|
|
rotation_x -= event.relative.y * mouse_sensitivity
|
|
|
|
rotation_x = clamp(rotation_x, -PI / 2.0, PI / 2.0)
|
|
|
|
rotation.x = rotation_x
|
|
rotation.y = rotation_y
|