With the transition between Idle and Jump configured in the Animator window, we can script a piece of code to trigger it. With the following recipe, we show how simple it is to control animations through scripting with Unity.
As usual, we follow on from the last recipe. You just need to add a
C# script in the
Scripts folder of the project (as you learned in Chapter 2, Importing 3D Graphics) and name it
Scriptsfolder in your Project panel and double-click on the newly created script to open it in Monodevelop, the default Unity script editor.
Animatortype variable to store the reference to the character animator and add the following ...