- Home /
Is it possible to exit any state in sub-state machine?
I'm trying to create a logic, where no matter which state I'm in I want to exit state machine (and go to parent level). I could connect every state to ExitNode, but that seems like a lot of duplicated transitions. My initial idea was to connect AnyState to Exit node, but that is not allowed.
So how do I do that in Mecanim?
Answer by jeango · Aug 29, 2020 at 10:26 AM
Hi, I know this is a pretty old question and all, but since I've had to look some stuff up myself, I thought it's worth answering.
The "Any State" state is not contextual to your sub-state machine, Any State refers to any state in any sub-state machine, not just the current one. So "Any State" should serve as an entry point to your sub-state machine rather than an exit point.
It makes no sense to have an "Any State" transition from your sub state machine to the lower level because well you could just as well do that from the top level itself.
This being said, if you really want a transition from ANY state to the exit node, then the solution is to create an empty node, transition from any state to that node, and make sure that transition has "Can Transition To" unchecked (this means that your empty state can't transition to itself from the Any State, preventing endless loops) and then have that empty state transition to exit.
Thanks for clarifying that any state is not contextual. Helped me a lot with understanding why is it set this way!
Answer by ggendron · Apr 02, 2019 at 09:56 AM
I'm very interested having an answer to that.
Couldn't we at least have an option to make the parent State Machine's transitions/conditions override anything in the active subState Machine (and therefore not needing the Exit node to be entered in order to exit the subStateMachine)?
In the current system I need to make a transition from each state in the substate machine to the exit node and it gets the graph totally unreadable (and losing lots of time everytime I make a change)
Answer by gkinder81 · Apr 27 at 09:03 AM
One workaround that may work in certain scenarios is to use a blend tree instead. That way you only have one state containing multiple animations to worry about. A tutorial showing how to do this for multiple idle animations can be found here - https://youtu.be/OCd7terfNxk
Your answer
Follow this Question
Related Questions
Mecanim. Why cant I get current state name? 1 Answer
Mecanim: different animations for a node 1 Answer
How do you check to see if an animation is playing in a Sub-State machine? 0 Answers
Mecanim : reference state machine animation 0 Answers
Reference clip for Additive blending animation in Mecanim 0 Answers