#camera rotation limit

2 messages · Page 1 of 1 (latest)

untold wagon
#

why does this @export var pitch_limit = 80.0 part of the script gives me the unexpected "identifier" in class body message?

extends Node3D

@export var mouse_sensitivity := 0.2
@export var pitch_limit := 80.0 # Proper declaration

onready var camera = $Camera3D
var yaw := 0.0
var pitch := 0.0

func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _unhandled_input(event):
if event is InputEventMouseMotion:
handle_camera_rotation(event.relative)

func handle_camera_rotation(mouse_delta: Vector2):
yaw -= mouse_delta.x * mouse_sensitivity
rotation_degrees.y = yaw

pitch = clamp(pitch - mouse_delta.y * mouse_sensitivity, -pitch_limit, pitch_limit)
camera.rotation_degrees.x = pitch
lilac dagger
#

Maby make it 80 instead of 80.0?, idk