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?

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.

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)

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 - Add Random "Bored" Idle Animations to Your Character (Unity Tutorial) - YouTube