- Home /
transition priority Any State vs specified state
Consider the following Mecanim transitions: A->B and [Any-State]->B. The animation controller is in state A and the conditions for both transitions are true.
Which transition becomes active and according to what criteria?
From my understanding, you can change the priority of transitions leaving a specified state. You just need to select the state and reorder the transitions in the list. However, the [Any-State]->? transitions do not appear in this list, only in the [Any State] list.
Any-State is just that, from Any-State to B, it's used for things like death where you could be running, walking, standing, swim$$anonymous$$g well any state as the name suggests.
What are you trying to use it for?
A is Idle and B is Attack. I'm using [Any State]->Attack because you can transition to attack from almost any other state, including attack itself.
Well I'm no expert on mecanim but I think any state needs to be for very specific event like death. Attack needs a more controlled method than any state.
You might get it working but it's probably better to make a more complex animator that considers what state you've come from.
I have 9 attacks and 8 B-actions. All attacks and B-actions (17 total) can transition to one another. Thus, the number of transitions between them is the combination "17 choose 2" times 2 (bidirectional). C(17,2)*2 = 272. $$anonymous$$anaging and tuning 272 transitions is unfeasible.
I know this is old so I don't expect this to be read, but it someone comes across this I would recommend not having the transition for A->B since it is already used inside [AnyState]->B. As for what comes first if you have both, I don't believe the order is something that you should rely on.
Answer by victor_Infinite · Apr 14, 2016 at 12:12 PM
Now with Unity state machine transtions, one option available to you is to add a statemachine that sets a boolean when entering the state, for example "preventanystate" when transiting to A and sets it to false when exiting the state.
Then in the transition from Anystate->B, this boolean is checked to be false. This ensures that B->A must be played instead.
Answer by pgomes · Jul 09, 2015 at 10:58 PM
From my experience so far, A->B takes priority over [Any-State]->B in a situation where both are valid.
Some of the comments bring up that you should probably try to avoid having both transitions altogether. However, in a scenario where you want to have tailored settings for a specific transition, and other settings for all other transitions, the direct alternative can cause a transition explosion.
Consider the following real scenario: I have 9 A-actions (attacks) and 8 B-actions. All attacks and B-actions (17 total) can transition to one another. Thus, the number of transitions between them is the combination "17 choose 2" times 2 (bidirectional). C(17,2)*2 = 272. Managing and tuning 272 transitions is unfeasible.
What is the solution to control this complexity? Use Unity 5 with sub-state machines. The new animation controller allows collapsing transitions by having generic transitions to a state, and transitions from entry state. This way we can have two sub-state machines, one for attacks, one for B-actions. Transitions to these two sub-state machines are made generic, instead of to specific states, and we add self transitions to each of the sub-state machines. See pictures for example setup.
Your answer
Follow this Question
Related Questions
How to fluently transition into an animation state? 0 Answers
Copy/Paste Mecanim Transitions 6 Answers
Mecanim opposite transitions. Easy made hard? 1 Answer
Mecanim - How to use "Exit Time" for a state that uses negative speed (anim playing backwards)? 2 Answers
Why, when I delete transitions from the Animator State Machine, do I get a null reference exception? 3 Answers