Godot Version
Godot Engine v4.7
Question
I’m new to Godot and have made my FPS camera have different rotation perimeters (can’t look straight down unless crouching and no limitations when airborne). My code works in that regard, but whenever the camera’s rotation is greater/lesser than the clamp angle limit (which happens when the character either lands on the ground looking between x >90° and <-90°, or un-crouches looking at x < -70°) the camera will snap to the limit whenever I move my camera. I’d like the camera to smoothly rotate back within the clamp boundaries without snapping or player input.
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) # Mouse lock
func _unhandled_input(event): # Camera rotation stfuf
if event is InputEventMouseMotion:
if is_on_floor(): # Camera sensitivity (Ground)
Head.rotate_y(-event.relative.x * MouseSensitivity)
else: # Camera sensitivity (Airborne)
Head.rotate_y(-event.relative.x * MouseSensitivity * 0.8)
Camera.rotate_x(-event.relative.y * MouseSensitivity)
if is_on_floor() and Crouch == true: # Crouch Perimeter
Camera.rotation.x = clamp(Camera.rotation.x, deg_to_rad(-90), deg_to_rad(90))
elif is_on_floor() and Crouch == false: # Standing Perimeter
Camera.rotation.x = clamp(Camera.rotation.x, deg_to_rad(-70), deg_to_rad(90))