javascript - How to get inverse of a lerp function -


this question exact duplicate of:

speed = math.lerp(speed, goalspeed, time); 

this code increases speed close goalspeed , slows down approaches it. how can flip around accelerates , begins speed approaches it?

this simple answer, it's been evading me ten minutes though. :)

beginning 1% of goalspeed below code helps increase speed speeds up:

speed = 0.01 * goalspeed; // initial speed speed = speed + math.lerp((goalspeed - speed), goalspeed, time); 

//round when speed crosses goalspeed , stop.


Comments