How to use root motion transition animations (e.g. Walk to Stop) without overshooting the destination?

I’m using MecanimBridge and a Recast graph for an AI character. My walk to stop animation is annoyingly long (and shortening it makes it almost impossible to sync properly).

My first thought was to fire an “about to arrive” event some distance before arrival, and trigger the transition then. However since the character’s speed is variable and from a blend tree, I haven’t been able to get the character to arrive at the destination even remotely accurately and reliably.

My next thought would be to calculate the time to arrival based on the current speed, and fire the transition when its calculated time matches the calculated time for the transition to complete. Is this the right way to do it? Should I measure in frames instead of time? If so, how do I calculate this?

I think that’s the right way. Though it might be easiest to just tweak a value until it looks good, theory can only get you so far when animations blend together in different ways.
The script does calculate exactly when it will reach the destination, but it’s kinda buried deep into the code. It’s in the MovementUtilities class in the CalculateAccelerationToReachPoint method. The code does a binary search to calculate approximately how long it should take to reach the destination (the result is stored in the mx variable). You could use that if you want, but it might require some digging to extract it.

I think trying to get a character to arrive at a destination with purely root motion is pretty much infeasible without a lot of advanced calculations. Instead, you can do it as a best effort and then try to slide the character while it is moving so that it will end up at a much more precise position. A small amount of sliding while the character is moving is rarely noticeable. This is what is commonly done in game with root motion that also require the character to end up at a precise spot (at least the games without a huuge budget :p).

I think trying to get a character to arrive at a destination with purely root motion is pretty much infeasible without a lot of advanced calculations.

Isn’t this basically what MecanimBridge is doing? Using root motion to drive a character’s X & Z movement?