-2
\$\begingroup\$

Am I right about the fact that lerping can be done over a set period of time or at a speed which will continue until the target is reached?

How are the formulas for the two? Is it something like this?

LERP at speed:

// does not use start value but instead current value
newValue= Lerp (currentValue, targetValue, Time.deltaTime * speed);

LERP over set duration:

//uses startValue and calculates the progress percentage over time
var newValue = Lerp (startValue, targetvalue, percentage);
percentage= (Time.time - startTime) / duration;
\$\endgroup\$
1
\$\begingroup\$

If you're using speed (particularly variable speed) until some target position (especially if the target can move) is reached, it's not really LERPing. That's more akin to steering.

If you do have a fixed distance to cover and a fixed speed then you can easily calculate the time to LERP over. Remember the units of speed are units of distance over units of time. Assuming your fundamental units agree (e.g. not mixing miles-per-hour with meters and seconds) then you can get the time to LERP over with a teensy bit of algebra, giving you time=distance/speed.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.