I want my character to go to the Move state whenever Speed is larger than 0, from any state. Setting a transition from Any State to the Move State with the Speed > 0 condition, makes the Move animation restart again and again. Can I fix this somehow from a script?
Hi. What happens is that you tell the system that in "Any state" that you are in, when Speed > x, transition to Move. So even when you are in Move, the transition is called ! A way to prevent this, would be to add a bool Parameter called InMove and add the condition "InMove is false" to your AnyState Transition. You set the bool to true when you enter the InMove state. We have internally discussed to prevent AnyState transition re-entering the same state but decided to allow it, since it can be usefull in some instance! cheers.
Hi thanks for responding. Could you give an example for when re-entering the same state again and again would be useful? I think it would be a lot more useful if this behavior was not the default but rather an option perhaps on the transition from Any State
Cant remember precisely why, but some team wanted to be able to re-enter the same state again.. which to think about it, is kinda odd.. So we changed the code base on our side, and made it impossible to re-enter the same state from an AnyState transitions.. You will have it on a future release ! until then us what I suggested above
Cool thanks for the fix Now if anyone were to answer this post it would be awesome: http://forum.unity3d.com/threads/159160-Mecanim-and-asset-bundles
Excellent. Looking forward to the fix, because my state machine is already spaghetti: http://youtu.be/wO3C_7D-aQU
Hi Jamie. I would also suggest using sub-stateMachines. We made numerous workflow fixes in the next version, that will make it super easy to drop states in and out of stateMachines. Should make the graph less spagethi-like!
So guys, finally we have users that already rely on AnyState to transition states to self. So the fix won't be in 4.1. We started designing a system when we could reset some values to default when some transitions are taken. It won't be in 4.1 however. Unitl then, I would simply suggest that you give a name to your transition, and then in code do something like : if(animator.IsInTransition(0) animator.GetAnimatorTransitionInfo(0).IsUserName.("NameOfTransition")) animator.SetFloat("SomeValue", resetValue); hope this helps. cheers.
Only one time it runs right, when i set bool Parameter "inMove" to true, but I can't get when it's transition "Any State" to set inMove to false . Thank you.
hi! pierrepaul i think the re-entering the state thing, is somewhat related to http://answers.unity3d.com/answers/627139/view.html and it's the same problem what I'm experiencing now.
Hi Since 4.3 you have Parameters of type Trigger which are automatically reset to false when the transition starts. pp
While the trigger parameters clear up the vast majority of the issues, I still feel that the system needs to change so states cannot transition into themselves. It's a very strange 'feature', and I have to work around it far more often than I get to take advantage of it. From the sound of it, you understand that it behaves in a strange way and would like to change it, but are worried that changing it now will corrupt any projects that rely on it. What if you made it an option on every state (should the state be reentrant or not) that defaults to false on newly created states, but is set to true on all pre-existing states when the project is converted?
As it happens, Unity 4.5 shipped today and (I believe) contains exactly such an option on all transitions from the Any State