Click.
Bam!
BOOM💥
START
Drag A and B to interact

Code Snippet

How does Lerp work?

The Basic Formula

Lerp stands for Linear Interpolation. It takes three arguments: a start value (`A`), an end value (`B`), and a weight (`t` or `alpha`).

Result = A + (B - A) * t

If `t = 0`, the result is exactly `A`. If `t = 1`, the result is exactly `B`. If `t = 0.5`, the result is directly in the middle.

The Smoothing Trick (Asymptotic Averaging)

Often, game developers use Lerp *incorrectly* for smoothing cameras or chasing objects by doing something like:
current = lerp(current, target, 0.1)

While this creates a nice "ease-out" effect, it is fully dependent on your framerate. A player running at 144Hz will have a much faster camera than a player at 60Hz.

To fix this, you use **Frame-Rate Independent Lerp** using delta time (`dt`) and a decay rate:
current = lerp(current, target, 1.0 - Math.exp(-decay * dt))

Extrapolation (t > 1 or t < 0)

What happens if `t` goes beyond 0 or 1? Depending on the engine, `Lerp` might be clamped (meaning it stops hard at A or B). If the engine provides an `LerpUnclamped` function, pushing `t = 1.5` will actually push the result 50% *past* point B in the same direction!

Answers to Common Developer Questions

What does LERP mean in game dev?
LERP stands for Linear Interpolation. It is a mathematical function that finds an exact percentage point between a precise Start value and End value. For example, Lerp(0, 10, 0.5) returns 5 (exactly 50% between 0 and 10).
How do you use Lerp for smooth camera movement?
Instead of moving a camera instantly to the player's position, you update the camera's position every frame using an easing metric: `camera.pos = Lerp(camera.pos, player.pos, 0.1)`. This mathematically creates an asymptotic 'easing' effect where the camera smoothly trails behind the player without ever snapping.
What happens if my Lerp 't' value is strictly greater than 1?
Standard Linear Interpolation clamps the 't' value (the percentage) between 0.0 and 1.0. If you use an unclamped Lerp (often called LerpUnclamped) and pass a 't' value of 2.0, the function will actively extrapolate past the End point, extending the imaginary line identically forward.