class_name CameraController extends Node3D ## Simple first-person camera motion controller const PITCH_LIMIT := deg_to_rad(85.0) @export var yaw_root: Node3D @onready var _target := Vector2(rotation.x, rotation.y) ## Rotate the camera by the given motion vector. ## ## The input motion vector is the change in pitch and yaw in radians. func camera_motion(motion: Vector2) -> void: _target.y -= motion.x _target.x = clampf(_target.x - motion.y, -PITCH_LIMIT, PITCH_LIMIT) func _physics_process(delta: float) -> void: var accel: float = ProjectSettings.get_setting("game/config/input/camera_acceleration") var weight := 1.0 - exp(-accel * delta) yaw_root.rotation.y = lerp_angle(yaw_root.rotation.y, _target.y, weight) rotation.x = lerp_angle(rotation.x, _target.x, weight)