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.
Go to the Project panel and find the Walk and Run clips of your character. Drag them from the Project panel into the Animator window.
Right-click on the Walk animation and make a transition to Run and another back from Run to Walk.
Create a new parameter, this time a
float
variable, and name itfSpeed
. The following screenshot shows the result you should have so...