By making transitions between animation states conditional, we enable the whole animation of a character to be driving through in-game events and scripting. Unity Animation Controllers provide a range of different types of parameter, from simple integer and float numeric values to true/false Boolean variables, and consumable Boolean "triggers."
While sometimes we do want an automatic, timed transition from one animation state to another, in many cases, we need to uncheck the Exit Time property for Transitions and define the appropriate condition for when we wish the Animation State change to take place.
In this recipe, we created a parameter named Speed, whose value we set in our script based on the vertical input axis. Unity's default input setup means that the W/S and Up/Down keyboard keys affect the vertical axis values in the range -1 ... 0 .. +1. Our scripted variable, vertical, is set based on this Unity input axis: vertical...