How to sync normalizedTime between states in an Animator?

I’m playing around with Mecanim and I want to get a character to switch between 8 different directions of movement. If I go up, it’ll play the up animation, if I move left, the left animation, etc.

The problem I’ve found is when I rotate quickly in a tight circle my character resets to the first frame of each animation and appears to be stuck in a neutral pose. I want the transitions between my run animations to maintain the normalizedTime of the last so if I rotate quickly then my character will still appear to run normally.

Is this possible to do in Mecanim? I’ve been searching for a solution for the past couple days and I’ve found next to nothing. Behaviors seem very rigid. I tried making a behavior that sets a parameter in the animator for the current animation progress and update animations with it, but it seems to reset normalizedTime regardless of my efforts.

I’m heavily considering using Animations with an array of AnimationClips instead of Mecanim so I can have tighter control of everything, but it would become a nuisance later on when I have a lot of animations playing.

Thanks

I solved the issue by using blend trees! Turns out by having all 8 directions of the run animations in a blend tree will actually keep time consistent across the animations. Now I have two states for idle and running, each with their own respective blend trees. I use parameters for x and y movement and 2D freeform cartesian motion in the tree to interpolate between the 8 animations.

This actually makes a lot of sense and ends up being much cleaner than either of the two implementations above. I’m really glad I started looking into blend trees, I thought it was just a 3D feature but it turns out it can be invaluable in 2D games as well!

2 Likes