Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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;
share|improve this question

closed as unclear what you're asking by BlueRaja - Danny Pflughoeft, Josh Petrie Feb 8 at 20:07

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer 1

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.

share|improve this answer

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