I'm having another Unity problem. As far as I can tell, the issue comes from trying to trigger a state transition while already in another transition. I'm using Animator.SetTrigger to blend between idle, walk and run animations, where I have three triggers named idle, gait and run respectively, and transitions in Mecanim that are triggered by those. idle is triggered when left/right is released, and gait and run are triggered when left/right are pressed or shift is pressed/released.
If I play the game gracefully and allow the full transitions to take place (0.1–0.4s each) then there are no problems. If I play erratically and, for example, stop and start or turn around too quickly, then a bizarre event happens where part of the animation plays out but then the character freezes pose for about a half second before resuming motion. I recorded a clip of the phenomenon. At first I show the animation behaving properly. Then I show it getting stuck:
https://youtu.be/TC-xM7AxxLQ
If it helps, I also have a screenshot of my current mecanim setup. I don't know if this has anything to do with my problem but you'll notice idle, run and gait all link back into themselves. The reason for this is the animations weren't looping, just pausing at the end of the animation cycle.
edit: okay, I didn't really fix the underlying problem, but this bandaid fix is good enough for now.
Code:
if (anim.IsInTransition(0)) {
anim.PlayInFixedTime(s, 0, 0f);
} else {
anim.SetTrigger(s);
}