CrossFade to Specific Animation Time (Coordinate Animations)

I have a character that is controlled by the player. I crossfade between running and walking animations regularly. However, it looks like he missteps sometimes when the animations crossfade to the incorrect starting position. Ex. he has his left foot forward but the new animation starts with his right foot forward.

Is it possible to CrossFade from one animation into a specific starting time of another animation?

Edit

I tried the following method:

When crossfading from Walking → Running

  • Get the current walking animation time using animation[“walk”].time
  • Calculate the time passed as a ratio:

var ratio = animation["walk"].time / animation["walk"].length // assume Wrap Mode "Once" is used for this example

  • Crossfade to the running animation, and set the time based on the calculated ratio

    animation["run"].time = ratio * animation["run"].length;

    animation.CrossFade("run");

This sort of works, but it will need a lot of polish to get it looking good. I’m wondering if anyone has thought of a better solution to solve the misstepping problem.

[Untested] crossFade(“run”) starts the run animation, at frame 0, and fades out whatever was playing before. The trick is to start run at a different frame:

animation.CrossFade("run"); // restarts run, at frame 0
// assuming walk/run are similar: rightFoot/leftFoot, put run
//   in similar position as walk:
animation["run"].normalizedTime = animation["walk"].normalizedTime;

If you’re using the set-up where you constantly crossFade to run at high speed (since crossFade when you’re already doing it, knows not to restart.) Then you’d have to somehow say “only figure runs new time if I am just now switching, from walk.”