Godot Version
4.6.3
Question
Why does the camera do that? How do I fix it? I didnt move the cameras position at all. The clamp also doesn’t work.
code for camera_controller. Rotation code is in _input.
var movement_dir = Vector3.ZERO
var velocity = Vector3.ZERO
var speed=1
var mouse_sens=0.001
var escaped = false
func _ready() -> void:
escaped=false
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func check_escape():
if Input.is_action_just_pressed("escape"):
if escaped==false:
escaped=true
Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
elif escaped==true:
escaped=false
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event):
if event is InputEventMouseMotion and Input.mouse_mode == Input.MOUSE_MODE_CAPTURED:
rotate_y(-event.relative.x * mouse_sens)
rotate_x(-event.relative.y * mouse_sens)
rotation.x = clampf(rotation.x, -deg_to_rad(70), deg_to_rad(70))
func _process(delta: float) -> void:
pass
func _physics_process(delta):
if Input.is_action_pressed("forward"):
velocity.z = -1*speed
elif Input.is_action_pressed("backward"):
velocity.z = speed
else:
velocity.z=0
position += velocity
check_escape()