Very Strange Problem (animator.crossfade)

Not technically an animation problem, but seemingly a problem with the cross fade functionality. Or perhaps I am just missing something.

I have over two dozen attacks per weapon type in my project, so I am no stranger to setting up attack states in the animator and I’ve never had this problem before. It’s very odd.

The Problem
When attempting a “Guard Attack” animation, the animation plays normally as it should. However if I spam the input, the animation still plays regularly but for a single frame the character model does the default no animation/avatar pose like this.

Gif Screen capture - a490c7f9e93bd6b7a53bcf3c6d7c4fb2 - Gyazo

Picture

It Gets Weirder

  1. If I place a “blank” animation state, and set it to transition into that state before going back to my default empty state. The bug does not occur.

  2. If I change “animator.Crossfade” to “animator.Play” the bug also does not occur.

Things I’ve Attempted

  1. I’ve tried different animations, they all have the same result.
  2. I’ve made sure the code that fires the animation is only being called one time (To call it again you must wait for the action to finish, which happens when it returns to the “Empty” state you see above)
  3. I’ve checked for other animations being played at the same time, there are none.

Update
I have no idea why, but for future people with this problem. This fixed it.

Setting the transition duration on the transition state from the attack to the empty fixes the problem. The weird part is, I have animations on this same layer where the “Transition Duration” is above 0. If somebody knows why this fixed the issue, I would love to hear it.

1 Like