Distance Matching Locomotion : Giving it a shot!

I looked back at my notes and noticed a typo—or, at least, a lack of clarity. In the way I’ve written things, the aB should be the magnitude of the BrakingDeceleration. (I like to keep my negative signs outside the parameters, when possible.) I’ve made the clarification in my notes below. (See after equation (3).)

That said, your RevAccel variable is probably already negative, if I’m understanding correctly, so the signs you and I have should be the same. I’m not sure what could be causing your error. I do, however, notice you use dt in one instance while using DeltaTime in another. I’m not sure whether you’ve defined those variables differently. Perhaps try coding in the following fashion:

SimulatedVelocity = SimulatedVelocity + (RevAccel + (-Friction * SimulatedVelocity )) * DeltaTime ;
StopLocation = StopLocation + SimulatedVelocity * DeltaTime;

DistanceMatchingNotes.pdf (174.6 KB)