Smooth Camera Pivoting with Stopping Points

You could try storing the desired rotation in a variable and using lerp_angle.

extends Node3D

@export var camera_target : Node3D
var target_angle: float

func _ready():
    target_angle = camera_target.rotation.y

func _process(delta):
    if Input.is_action_just_pressed("Rotate_L"):
        target_angle += deg_to_rad(45)
    if Input.is_action_just_pressed("Rotate_R"):
        target_angle -= deg_to_rad(45)

    # Change the constant (2) until you get the desired rotation speed
    var rot_weight: float = clampf(2 * delta, 0, 1)
    camera_target.rotation.y = lerp_angle(camera_target.rotation.y, target_angle, rot_weight)

I’ll admit I’m not 100% this’ll work, so sorry if it doesn’t, but hopefully it helps in some way.

2 Likes