Blending between large amount of animations inside Blend Tree.

I have Default State Blend Tree containing larger number of idle animations. Mostly I just switch to proper idle animation when different type of animation is running, so it’s ok that switch is instant. But in some cases I need to blend from one idle animation to another (blend animations inside one Blend Tree).

Clamping value is not an option as animations are usually not next to each other. Using 2D Blend Tree also cannot solve it because there is simly too much of them and it mixes more different animations together during transition.

Would it be possible to add some API function which can be used to blend between two animations inside one Blend Tree? That would be life saver.

Using a Direct Blend Tree lets you manage the weight of each state using a separate parameter, but then you have a bajillion parameters and still have to fade them in and out over time yourself.

Or you might be interested in Animancer (link in my signature) which lets you play whatever animations you want and control them freely without needing to use an Animator Controller. I can pretty much guarantee that it would let you implement whatever you are trying to do far more cleanly than that monstrosity you’ve currently got.

Unfortunately blending weights in code is not an option here. Too many clips in Blend Tree and mostly not next to each other.

I am aware of your Animancer. Looks great and has best reviews in whole Asset store. And I prefer coding over setting things in editor.
Reason why I hesitate at this moment is that I already invested a lot of time into animator controllers (have more like this, with some specific settings and a lot of code builded around it).
And second reason is that I am in general a bit scared to overuse third party assets, especially for fundamental game parts. I will spend several more years developing my game and don’t want to risk too much to being left with deprecated asset(s).

I will probably watch situation about Mecanim for some time and see if there is some further development in this area. And if not, I’ll jump into Animancer.

Animancer Pro gives you the full source code so you can always fix bugs or modify it on your own if necessary and it also supports a Hybrid approach where you use an Animator Controller for some things and Animancer for others.

Hey @Michal_Stangel , this function Unity - Scripting API: Animator.CrossFadeInFixedTime is pretty handy for just fading across to any clip with minimum fuss. The clips will have to be sitting in the animator controller though as seperate nodes. I’ve found it a bit of a sanity saver.

Thanks for suggestion. Unfortunately, if I understand it correctly, CrossFade function will not work for transition between 2 clips inside one Blend Tree.

No sorry :frowning: you’d have to pull them out of the blend tree. Just letting you know another option.

I understand. But I have too many Idle animations and number is growing. Plus Idle Blend Tree serves as main hub connecting all other States and Blend Trees.

It’s probably doable to separate all Idle animations, but far from ideal.

@Michal_Stangel I’m just starting to try and get my head around how to handle layers and blend trees when you have a large number of animations and was wondering if you would be comfortable sharing some screenshots that show how you’ve approached structuring yours. The only thing I’ve found so far that has detail beyond how to do simple blends like from idle-to-walk-to-run is this: Pixel Crushers - Layered Blend Trees in Mecanim, which may or may not be of some help to you. They mention at the end of the article utilizing Animator.CrossFade to reduce the number of transitions.

It still isn’t clear to me, though, how to best to divide and conquer such large numbers of animations - e.g separate blend trees, layers, CrossFade, etc. I thought I would make an attempt at understanding elaborate blend trees as if I was doing a bare bones COD type game using Mixamo animations. The included screenshots illustrate where I’m starting from. The zoomed-in image represents forward movement. In the wider image, the other parts are basically identical to forward movement, with the other branches representing animation blends for Idle, Move Backwards, Move Sideways Left, and Move Sideways Right. For clarity, I adopted a naming convention to distinguish nodes more clearly: st - a single state, bt - blend tree, tr - transitional animation between two nodes.

Just wondering if this bears any resemblance at all to how you’ve approached it.

Thanks!

Hello,

My problem is transitioning between clips inside one dimensional Blend Tree (specifically between different Idle clips) when this Blend Tree (state) is active. CrossFade is probably not usable here as it transitioning from one state to another.

I doubt that Unity will add this feature, so I did this workaround:
I have too identical Idle Blend Trees and if I want to change Idle clip when in Idle I first set proper float inside second Blend Tree which is not active (called “Idletransition” in enclosed screenshot). Then I immediatelly call transition to this Blend Tree (or you could use CrossFade). At the same time I also schedule coroutine which will set same (new) float inside first (main) Idle Blend Tree and force transition back to it. Delay is currently set to 1 sec.

I just did it, several minutes ago, in order to give you some response, so possibly there is some catch. But at first sight it looks quite good :slight_smile:

5988185--643871--Idle transitioning.jpg

@Michal_Stangel Thanks for sharing that. I will dig in a little more deeply after resolving a wholly separate problem I’ve been sidetracked with. There never seems to be an end to those. :smile: Hope your solution ends up being the successful solution for you.