- Home /
Using Mecanim animation state machine, how can a state transition to itself?
There doesn't appear to be a built in way to have a state transition to itself. A trivial example of when this would be desired is in a melee combat system, where PunchLeft can be done twice in a row.
Doesn't seems to be possible. I have the same problem with run and walk, I would like to stay in the run state ins$$anonymous$$d of going back to walk. I guess I can solve it with a blend tree, but in your punch example I don't know how it's supposed to work...
Answer by yamaciller · Jan 29, 2013 at 09:53 PM
Simply loop the punch while the key is pressed. If you have a leave condition, just leave the state to a different one.
Answer by Staross · Feb 01, 2013 at 06:22 PM
So playing a bit with it, the trick is to make sure all transitions conditions are false and the animation is looped.
Answer by wren945 · Mar 29, 2013 at 08:31 AM
I wonder why it cannot transit to itself. Unity has this problem from the legacy animation system, and they solved it with functions like PlayQueued/CrossFadeQueued, which was really not intuitive.
Answer by Durabel · Sep 13, 2014 at 09:24 PM
Have two identical states transit to each other on the same transit condition.
Your answer
![](https://koobas.hobune.stream/wayback/20220613085401im_/https://answers.unity.com/themes/thub/images/avi.jpg)