Why is Lerp slowing down in Unity?

In by John FrenchPublished

The slowing effect caused by using Lerp to move an object towards a target position is caused by using Lerp with Time Scale.

Like this:

transform.position = Vector3.Lerp(transform.position, target.position, Time.deltaTime);

This causes a value to move towards its target by a fraction represented by the duration of the last frame.

However, because the start value (A) is the current value, not the true start value, this causes the fraction of movement to become less and less each frame, causing an easing effect.

Like this:

The wrong way to Lerp

This slowing effect is caused when using Lerp to ease a movement.

Technically, this is an incorrect use of Lerp, where normally Lerp would be used to return a weighted value on a fixed scale.

Instead this easing method uses a dynamic start value and passes time scale in place of T, causing the easing effect.

While this isn’t the intended use of Lerp, there’s nothing wrong with using it in this way, if you want the effect that’s created.

The drawback of using Lerp in this way is that it can be difficult to control the rate of movement, as the speed of change is based on frame time, instead of a controllable value, such as duration or speed in units per second.

As a result, alternative methods of easing, such as Smooth Damp, may be preferred.

See also