Blend trees are a means of taking supposedly similar animations such as walking and running and blending the angles and positions of bones according to some weight. Unity makes blending multiple animations across a plane, via two independent weights, a breeze.
Though a static animation such as crouching or reaching up in a pose typical of max-height while jumping might not be considered "similar" to running, blending is actually incredibly flexible. In this case I'm using 4 animations blended with a single blend tree, three of which are actually completely static: aside from running, jump, idle, and crouch are a single-frame animation.
The four animations are spread across a speed-jump plane so that crouch, idle, and jump are stationed at zero speed and different jump levels, and running is on a jump level of zero and a positive speed. At each frame the speed and jump determine the point on this plane the blend tree is on, and the four animations are interpolated accordingly.
The tree itself is not overly complicated:
And the animator's state machine borders on silly, containing only the blend tree as sufficient for all needs:
Of course, adding the next animation - throwing - will require another layer of states, but the default layer is actually expected to remain this simple.
The only thing to keep in mind is that the jump level and speed themselves must change continuously for the animation to be fluid. Luckily, Unity makes that easy as well, using one of my personal favorites: Mathf.SmoothDamp.
Comments