Search code examples
c#unity-game-engineanimationanimator

issue using "Any State" in Unity Animator


So, i am making a little 2D game, and in this game the player can snowboard, so, i made the player animator, and i wanted the player to snowboard doesn't matter the state, so i used the "Any State" state to transition the current animation to the "9_Snowboarding" animation using a bool called "isSnowboarding", and it worked fine.

First Image

The problem began when i wanted the player to jump, i created the jump animation, and i created a bool to make the transition happen called "isJumping", and i set the bool to true by code.

transition settings

Instead of transitioning to the animation and playing it, the animator controller keeps transitioning the "9_Snowboarding" to the "10_SnowboardJumping" multiple times, and i dont know how to solve this.

animation keeps transitioning


Solution

  • Particularly in your case you need to use a "trigger" instead of a "bool" parameter.

    The problem with bool is that isJumping is always set to true so your condition keeps on matching and you keep on transitioning to the same animation.

    "Triggers" on the other hand will disable once used. So try adding something like Jump trigger and set that in your code