Unity: Animator Any State

Using Unity’s Animator controller, sometimes simple things can get out of hand. You can either make your custom solution or sometimes Unity provides the answer to you. Any State transitions are something like the latter.

It is a transition state that can go to an animation state from any animation state. It uses a trigger to decide which state to go to next.

Note: Using Any State is suppose to add a tiny overhead cost to the animator but that cost can be minimal in comparison to the complexity of the animator.


Let’s take an example of normal animation states and how Any state can potentially replace this clunky setup.

In this example, I go from State 1 >> State 2 >> State 4 >> State 3 >> State 1 >> State 4.

Here we have an animator triggering the change in size of the white box. Each state can go from one state to another changing the size of the box. Using transitions and triggers we have 4 animation states with 12 transition states between them. Giving us every combination possible. Now let’s convert this transition setup to an Any State Transition setup.


Any State transitions setup

We will now change our Animation Transitions to the Any State setup with the same robust setup that allows us to move from any one state to another.


1. Drag Any State to the middle

Delete all existing transition states to each of the animation states. Drag the Any State to the middle of the Animation states.


2. Make transitions from Any State

Make transitions connecting Any State to each Animation state. Note, you don’t have to make reverse transitions going from Animation state to Any State.


3. Add a trigger to each transition

Any State will be ignored unless you define a trigger for the transition states. Add a trigger to decide how the transitions will change. In my case, I used an integer to define the trigger for each state. (eg. State 1 transition has an Int Trigger value = 1).


4. Set your default trigger value

Set your trigger value to the default state. In my case, my default Animation State when the animator is enabled is State 1. So, I set the default trigger value to 1.



The resulting setup is a lot modular to work with. With just 4 transitions we can go from and to any Animation State. Any future changes and updates will be a lot easier to implement. It is also easier to debug. This might seem like a simple example but notice how crazy things can get, when we add just 2 more Animation states to the original Animator Controller.

This is similar to what we were using in my current game.


And this is what it looks like now, after using Any State