Using blendTrees instead of state machines

Hello!

I watched a GDC video related to animation and the advice was replacing all the state machines with blendtrees to have more control over blending between states. I’m very interested in knowing how one could implement such a system.

How would you do something like the animation he shows when you fall, hit the ground, and blend into the crouch movement and then back to idle using blendtrees?

Thanks :pray:

You may need this Playables API, and
animancer-pro

1 Like

I see. Would you know how this can be achieved using Animancer pro? How would you make the jump for example with this kind of trees?

Animancer isn’t the solution you’re looking for here. That’s a great asset for being able to play clips without needing them in a tree and has nice features like callbacks when the clip is done playing which you don’t get from the Animator, but it’s not what you’re looking for.

Blendtrees can get out of hand pretty quick when doing what the video is talking about. Unity lags when I try to update my locomotion blendtree for the game I’m currently working on because it’s really a blendtree of blendtrees of blendtrees blended on a 2d horizontal/vertical movment, then weapon type, then if aiming or not (and then a bonus blendtree for idling which is where I can dynamically mix around other idle animations):

What might work but isn’t ideal is to have a traditional blendtree for movement like you’re used to, but then instead of blending into 8 way movement clips, you instead blend into another blendtree for standing/crouched. I do that here:

This isn’t ideal because it’s a pain to add another layer. Let’s say you want to expand this to now have different weapon types or aiming weapon/not aiming weapon blends. It’s a huge pain to change around an existing blendtree like this.

For something like landing on the ground, it’s great to use additive layers that “add” bits of motion over the normal animations playing back. You can have a blendtree set to Direct with an animation for landing and then blend in more or less of that animation depending on how far the fall was.

Hopefully that at least slightly helps. You can’t replace everything with a blendtree because it’s still limited that time is always flowing forward, so you can’t blend from halfway through your walkcycle to the beginning of a ground land all in the same tree. But blendtrees are great for encapsulating lots of similar motions together since transitions in Animators are really where most bugs happen, so try to get rid of as many transitions as you can.

1 Like

Thanks for the explanation, the images with examples are very helpful!
Then, I might use a blend between the two methods depending on the situation :slight_smile:

1 Like