Camera distortion

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()

Please elaborate. As it stands, your posting is too vague to be answerable.

is your camera child of node that moves? also try clamping with pi instead of angle

e.g instead of -deg_to_rad(70) use -PI / 2 to PI / 2 - e.g -90 to 90 and try that, maybe it’s due to degres conversion

also be sure that you’re rotating camera on correct axis, try both y and z, not only x

why are you being vague

switching rotate_x() to rotation.x-= fixed the clamp

clearing the translations on the camera node fixed the weirdness