i tried to clamp the rotation value of the camera but it doesn't work

`


extends Marker3D
@onready var Camera = $HorizontalAxis/VerticalAxis/CameraSpringArm/Camera
@onready var Horizontal: Node3D = $HorizontalAxis
@onready var Vertical: Node3D = $HorizontalAxis/VerticalAxis
@onready var CameraSpringArm: SpringArm3D = $HorizontalAxis/VerticalAxis/CameraSpringArm

var h_accelaration = 0.3
var v_accelaration = 0.3

var cam_rotation_h = 0.0
var cam_rotation_v = 0.0

func camera_event(event: InputEvent) -> void:
	if event is InputEventMouseMotion:
		cam_rotation_h += -event.relative.x
		cam_rotation_v += -event.relative.y
		

func toggle_mouse_lock() -> void:
	if Input.is_action_just_pressed("a_toggle_mouse_lock"):
    	if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
	    	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	    else:
	    	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)


func _input(event: InputEvent) -> void:
    camera_event(event)
    toggle_mouse_lock()


func camera_rotation(delta: float) -> void:

    Horizontal.rotation.y = wrapf(cam_rotation_h * h_accelaration * delta, 0, deg_to_rad(360))
    Vertical.rotation.x = wrapf(cam_rotation_v * v_accelaration * delta, 0, deg_to_rad(360))
    var camera_rot = Vertical.rotation
    camera_rot.x = clamp(camera_rot.x, -70, 70)
    Vertical.rotation.x = camera_rot


func _process(delta: float) -> void:
    camera_rotation(delta)

`

Rotation is a Radian, not a Euler angle. You can use deg2rad() (Godot 3.x) to deg_to_rad() (Godot 4.0).

camera_rot.x = clamp(camera_rot.x, deg_to_rad(-70), deg_to_rad(70))

    cybereality thx and there was another problem wrapf it messed up the rotation so i removed it
    Vertical.rotation.x = cam_rotation_v * v_accelaration * delta

      jackdaw please try to avoid using swear words, it's against the forum rules. I've edited your post and just leaving you with a warning this time.

      a year later

      cybereality yes but no,
      this work if only I slowly move mouse, otherwise clamp breaks down if quickly jerk the mouse (for exp) in left and camera instantly rotating from -70 to 70 deg ...
      the same thing happens on all axes, the camera can still rotate in a circle, but without the possibility of remaining in the dead zone

        KenSteelyHunter
        this works:
        first script:

        Click to reveal Click to hide

        `func _input(event):

        # Mouse looking
        if event is InputEventMouseMotion:
        	#const freelookClampAngle = deg_to_rad(135)
        	var mouse_x = deg_to_rad(event.relative.x * -_mouseSens)
        	var mouse_y = deg_to_rad(event.relative.y * -_mouseSens)
        	
        	if freelooking:
        		ExtraMethods.clamped_rotate_y(neck, mouse_x, 2)
        	else:
        		rotate_y(mouse_x)
        	
        	ExtraMethods.clamped_rotate_x(head, mouse_y, PI/2)

        `

        And salt (extension script):

        Click to reveal Click to hide

        `class_name ExtraMethods extends Node

        static func clamped_rotate_y(object, amount = 0.0, clampAngle = PI):
        if amount > 0: # in left
        var dostup = clampAngle - object.rotation.y
        if amount < dostup:
        object.rotate_y(amount)
        else:
        object.rotate_y(dostup)
        else: # in right
        var dostup = -clampAngle - object.rotation.y
        if amount > dostup:
        object.rotate_y(amount)
        else:
        object.rotate_y(dostup)

        static func clamped_rotate_x(object, amount = 0.0, clampAngle = PI):
        if amount > 0: # in left
        var dostup = clampAngle - object.rotation.x
        if amount < dostup:
        object.rotate_x(amount)
        else:
        object.rotate_x(dostup)
        else: # in right
        var dostup = -clampAngle - object.rotation.x
        if amount > dostup:
        object.rotate_x(amount)
        else:
        object.rotate_x(dostup)
        `

        use
        p.s. post's metablocks for inserting code do not work correctly