In the following recipe, we will show you how to use a float
type to switch between clips based on a value that changes continuously, such as the character speed.
Let's assume we have an animation loop for the walking state of the character and another for running. As the character speed increases, it switches between the two states. How can we achieve that? Check out the following recipe to know.
As usual, we follow on from the previous recipe. Have the FBX files named Char@Walk
and Char@Run
imported and available in the project panel and the Animator window open in the editor.
float
variable, and name it fSpeed
. The following screenshot shows the result you should have so far:fSpeed
as the parameter to blend between Walk and Jump.float
variable as the condition for the transition, we are also required to refine the condition itself by setting whether we want the transition to be performed once the value gets larger or smaller than a threshold we set. Set the threshold
condition for our float
parameter to Greater and set its value to 0.5
. This way, the running clip is played as the character speed grows. Please refer to the following screenshot:We added some complexity to the animation system of our character by adding a transition controlled by a float
value. We used the float
value to blend between the Walk and Run clips, based on the character speed. Assuming an analog control system, with this setup, the character switches between the Walk and Run clips based on the player's input.
3.138.37.20