I'm trying to slow down a object over different distances in the same time, say 3 seconds.
My slow down code is.
function lerpSpeed (speed: float, lerpSpeedTime: float) { incomingFlightSpeed = flightPathScript.flightSpeed; i = 0; while(i < 1) { i += Time.deltaTime/lerpSpeedTime; i = Mathf.Clamp(i, 0, 1); flightPathScript.flightSpeed = Mathf.Lerp(incomingFlightSpeed, speed, i); yield; } } So I call it with.
waypointScript.lerpSpeed(1,(totaFlighpointsDistance/flightSpeed)); In the picture below I've draw a bezier curve and at the last 8 flight points (the red and yellow spheres) I want to start the slow down from the yellow sphere to the last red sphere.
I get the distance in between each of the last 8 flight points and total them up to give me the total distance, I understand to get the time it will take to travel that distance is time = total distance/speed, but as I'm slowing the speed in my function above this will not work.
And because every bezier curve I generate is different, some stretched out, with total distances sometimes ranging from 30 to 8.
So I'm a bit stuck here, thought I'd get this one, but unless I'm missing something simple I can't get my head around it, so any help would be greatly appreciated, thanks.
