Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 448
Nícolas Avatar asked Dec 13 '22 15:12

Nícolas


2 Answers

Alternatively, if you absolutely need a bool there for some reason, you can disable the Option "Can Transition To Self" in the Transition settings of the Any State to your State Die.

AnyState Transition Settings - Can Transition To Self

like image 168
ForceMagic Avatar answered Dec 16 '22 05:12

ForceMagic


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

like image 24
Kashif Siddiqui Avatar answered Dec 16 '22 03:12

Kashif Siddiqui