# (Solved) Lerp formula for smooth camera angle

Hi there, so let’s say my character rotates with left and right arrow at 150°/sec, I wanna rotate the camera too, so the gameplay overall feels more alive and to increase the chance of players to get lost.

I guess one way would be like this:

But I wanna make it smooth, maybe applying lerp but I don’t know how, thanks for the help

Hi,
Here’s how lerp works:
Linear interpolation from A to B by X.
The expression you write in the field is: lerp(A, B, X)
where:
A - starting value (current position/angle/…)
B - ending value (desired position/angle/…)
X - speed of interpolation (higher goes faster)

2 Likes

Just to add to the explanation:

X is a value from 0 to 1.

Imagine there is a straight line between A and B. The value X represents how far along that line the returned value is; 0 indicates the start of that line (value A) and 1 indicates the end of that line (value B).

The X value of 0.5 is exactly the middle between A and B

The X value of 0.25 is a quarter of the way from A to B.

1 Like

Thanks guys, with that info I figured out it could be

Every frame > Change the camera angle set to lerp(Camera.Angle(),Player.Angle()+90,0.05)

And it works flawlessly, it wasn’t clear to me what lerp did before, thank you

1 Like