Im an experienced game dev hobbiest making my first game with 3d animated characters (in Unity) and am struggling to figure out when to use blend trees vs animation state machines. I understand both conceptually but have seen both blend trees and animation state machines used for character animation in a bunch of tutorials both from Unity and from other sources. I am not sure when / why one is better than the other am hoping someone can point me in the right direction.

My game is a 3rd person action rpg a'la WoW or KOTOR or Mass Effect (different systems I know but the perspectives and combat styles are kinda close at a high level). I have tons and tons of animations for attacks, blocks, feigns, deaths, walking, running, jumping, shooting etc but I am unclear on how to sequence them together naturally.

I have seen blend trees used for locomotion which makes sense to me when trying to keep character motion fluid, but I dont understand how to go from that blend tree to an attack state and nothing I have seen so far has gone past locomotion (no attacks etc). Do I need to make blend trees from my motion states to attack / death / dodge states? Do I have more control using just state machines? Im a little cautious of state machines because of the transition bloat that is so common with them and because I suspect there is greater potential for janky animation sequencing without blending.

I am planning to use the Unity character controller and write my own logic scripts to drive it. For the AI I will be using the built in nav mesh agents. Are character controller animations handled differently than the AI ones?

Any insights would be more than welcome!



1 Answer 1


I've worked quite a bit with Mecanim in Unity, and feel I have a quite good understanding of how it works.

Like you say, blend-trees are almost definitely the way to go for doing locomotion. Blend-trees are generally for when you want to continously blend animations to create the final output. Like give the player the control of how fast the avatar is running.

All single actions are likely better to keep as an individual state, which you can transition into. Depending on how intense your game is going to be, you may even consider using the Any State as a point of departure to quickly go to jump, attack etc., without having to wait for another animation to finish.

The key to blending from a blend-tree with running is to use transitions. There's no magic to make this look great, only careful planning, and tweaking while previewing the transition in Unity. A lot of the job relies on the animator for having the foundation for succesful transitions.

Something to keep in mind when doing transitions is to find the balance of them looking great, and giving the player the expected feedback. You may find that a quick transition works best for the game-feel, while a slower transition may look better but make your players want to throw away the controller.

Below is a somewhat simple setup, where arrows indicate how transitions go. Transitions are based on conditions for entering, and either exit when the animation finishes or a given condition is met. This also means that one state can go into various other states depending on different conditions.

State Machine

What you probably notice is that this quickly can become a big pile of "spaghetti", and a way to avoid some of this mess is to utilize the Any State which is also included in the image above.

The Any State has the benefit of being able to transition into anything from any given time. Transitions can still be used to blend the animation, however, you're working a bit more in the dark as to how it will look. It is possible to preview from/to various states while setting it up.

Something you didn't mention is Layers, which can be extremely useful for making your character wounded or to override the upper body to carry different weapons while using the same animation for the legs for all weapons. Layers are also blended and can be adjusted gradually, so a character could be more or less wounded, for example. Another example would be to lift a characters arms in the air (if the character surrendered or something), while keeping all other animation the same.

But setting up a solid animation controller is not a 1-hour job. It takes some planning and I can only encourage you try setting up a simple state machine with two attacks, a jump, an idle and a walk/run blend-tree. You may also find the Behaviours introduced in Unity 5 extremely useful for controlling or interacting with scripts.

I am 99% sure that AI will behave in the same way as the player controller, given that it is parameters changed through scripts that controls how the animation goes from state to state.


  • Blend-trees for locomotion.
  • States for single, defined actions or simple looping states.
  • Sub-states for organising a series of states, like a jump.
  • Transitions for blending/transitioning between different states (a state can also be a blend-tree).
  • Layers for overriding or adding to the base animation.

So think of blend-trees as expanded states, which also act based on parameter values.

A bit of a long ramble, but I hope it shines some light on the subject :)

  • \$\begingroup\$ Thanks for your awesome description, this makes a lot of sense now \$\endgroup\$
    – weichsem
    Dec 2, 2015 at 21:45
  • \$\begingroup\$ Fantastic, happy to help :) \$\endgroup\$
    – Morten
    Dec 3, 2015 at 10:25
  • \$\begingroup\$ Blend trees can also be used for things like creating facial expressions (blending the motion of various parts of the face to create a specific facial expression). \$\endgroup\$ Jul 13, 2022 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .