Blend trees in Unity enable the creation of complex, fluid, and responsive character movements. They allow the seamless blending of different animations based on the defined parameters, such as speed
or direction
. They offer a wide array of character behaviors, adding realism in the simulations.
If you want to mix the running, moving left, and moving right animations together, you can use blend trees to create smoother transitions between different forms.
Blend trees use nodes to organize and transition between various animations.
The types of nodes are explained below.
1D simple directional: It is used to blend animations based on a single parameter that moves in one direction.
The parameter can be the speed of a character.
As the value of the parameter changes, Unity transitions between different animations.
2D simple directional: It is similar to 1D simple node, but it uses two parameters instead of one.
It allows you to blend animations based on two different parameters, like speed and direction.
It is mainly useful for character movement, where you might want to blend between different running, walking, and idle animations based on how fast and in which direction the character is moving.
2D freeform directional: Similar to 2D simple node, it uses two parameters. However, it allows for more complex blending between animations.
Rather than transitioning in straight lines between animations, you can create more complex paths for transitions.
It is useful for the situations where you want more control over the animation blending.
2D freeform cartesian: It is similar to the 2D freeform directional, but it does not consider the magnitude of the parameters for blending.
It means that the blending does not depend on how far away the parameter values are from the animation thresholds.
It gives you even more control over the blending, but it comes at the expense of complexity.
Parameters are the variables that are used to control the blending of animations.
There are different types of parameters, explained below.
Float
: It represents a floating-point number.
It is often used to represent motions like speed or rotation.
Int
: Integer parameter represents whole numbers.
It is used for state transitions where each state is assigned a specific integer value.
Bool
: Boolean parameters represent a binary choice, often used for true
or false
state transitions.
You can use Bool
parameter to control whether a character is jumping or not.
Trigger
: Triggers are a special kind of Bool
that automatically resets its value to false
after it has been used.
It is often used for one-time events, like a character starting to jump.
By utilizing nodes, transitions, and parameters, you can control how different types of animations blend in Unity. Such control allows for a vast range of possible movements and states for the characters and objects in the game.
Once you double click the blend tree, you should be able to see multiple settings for the nodes.
Purpose of each of these settings is explained below.
Threshold: It determines the parameter value at which animations begin to blend.
It allows smooth transitions between various animations.
Change animation speed: It adjusts the playback speed of the individual animations in the blend tree for fine-tuning.
Automate thresholds: It automatically spaces the animation thresholds evenly.
It is useful for sets of similar animations.
Compute thresholds: It calculates thresholds based on the differences between animations.
It is useful for similar animations with distinct variations.
Adjust time scale: It modifies the animation speed according to the parameter value.
It is useful for matching animation speed with the movement speed of the object.
import React from 'react'; require('./style.css'); import ReactDOM from 'react-dom'; import App from './app.js'; ReactDOM.render( <App />, document.getElementById('root') );