Camera clamp stops working after I tilt it

Godot Version

4.4.1.0

Question

This line of code:
$Head.rotation.x = clamp($Head.rotation.x, deg_to_rad(-89), deg_to_rad(89))
Stops working after executing this other line:
if $Head:
$Head.rotation.z = lerp($Head.rotation.z, -input_x * tilt, lerp_speed * delta)

Head is the player camera

Rotations like this are generally prone to unintentional behaviour and gimbal locks. I suggest you read this article on how to setup a basic fps camera. For the tilt the simplest solution would be to add another node to their setup.

2 Likes