Lesson 46 +10 XP

Blend Trees

Blend Trees

In standard state machines, transitions jump between distinct states. Blend Trees allow you to smoothly blend multiple animation clips together based on float parameters.

When to Use Blend Trees

Blend Trees are ideal for character movement:

  • Blending from Walk to Run based on player velocity.
  • Blending directional animations (Idle, Walk Forward, Walk Left, Walk Right) based on coordinate inputs.

Setting Up a Blend Tree

  1. In the Animator window, right-click and select Create State -> From New Blend Tree.
  2. Double-click the Blend Tree node to enter it.
  3. Select the Blend Tree node, and in the Inspector, choose a Blend Type:
  • 1D: Blends based on a single parameter (e.g. forward speed).
  • 2D Simple Directional: Blends based on two parameters (e.g. Horizontal and Vertical inputs).
  1. Add animations to the Motion list.
  2. Define the threshold values where each animation is active.

Unity will automatically blend the bone positions of the character mesh based on the parameter values you pass from your scripts, producing smooth intermediate states.

TL;DR

  • Blend Trees blend animations smoothly rather than cutting between states.
  • Use 1D blend trees for linear actions (Walk -> Run).
  • Use 2D blend trees for directional movement (X, Y controls).
  • Blending calculations happen automatically on character bones.