So I have a really simple state machine. Theres literally an idle and a run. I’m using triggers to change states but I’m getting this problem… So basically lets say you’re idling, then you move, I set the Run trigger to true and it triggers the run, then I stop, and it sets the idle to true and plays the idle animation. I’m keeping track of what “animation state” you’re in, in my code, that way I can ensure it only calls the trigger once when needed. All of that works fine. But I get this problem where I can make the animation state get stuck in either of the states. I noticed that whatever trigger actually stays true until the transition is finished, this is not me, this is unity. So therefore, if I move, the run trigger gets set to true, then I stop during the transition, then move again quickly, it then gets stuck on the run animation. I know what the problem is, it’s unity not setting the trigger to false the next frame which is what the docs say which again, is a load of bollocks. Any help? Need to use triggers btw
Thanks to whoever helps ![]()
Can you post your code please?
– Griffosure thang void SetAnimation () { if (currentAnimationState != previousAnimationState) { switch (currentAnimationState) { case AnimationState.idle: { animator.SetTrigger ("Idle"); break; } case AnimationState.run: { animator.SetTrigger ("Run"); break; } } //update the previous animation previousAnimationState = currentAnimationState; } }
– NoUJoeYou should use boolean instead of the trigger for this kind of setup. Triggers have a weird behaviour that they never get deactivated unless the transition is played . You should use triggers for idle->attack.
– 0tacun