Mechanim animation Any State except current one
I have a 4-directional 2D animation controller (using Spine2D animations):
https://www.dropbox.com/s/gg56xo36v0wibur/mechanim_4way.png?dl=0
Direction: 1 is up, 2 is right etc. All animations loop. No transitions have exit time (they don't require a loop to finish), but all have an overlapping transition time (blending between states).
The problem is that Any State includes the current state, so if direction=1 and moving=true, the transition from Any State to WalkUp will fire over and over, without letting WalkUp finish its loop.
If I had a 0-second transition time, I could make direction=1 only for a single frame to indicate a change in state, then immediately set it back to 0. Unfortunately with a transition time, if that direction=1 happens during a transition, it will be missed.
If I set the exit time flag on the 4 Any State transitions, then animations would finish their loops before changing, which would work, but take too long making movement feel sloppy and unresponsive.
The obvious solution is to add transitions between every single state and the 4 run states. This feels like a hack when clearly this is what Any State was intended to simplify.
The only other thing I can think of is setting direction=1 then polling the animation state every frame until it changes, before setting direction back to 0. This also feels hacky... but maybe is the best solution?
Surely this problem comes up all the time in Unity... am I just going about it all wrong? Is there a better way to handle 4-directional 2d animation using Mechanim?
(Sorry image is a link, uploading images to unity answers is currently broken)