Getting ready

We are going to create this recipe from scratch and we don't need any special assets. You can download the example project and go to the Chapter 10 MiscellaneousRecipe 05 Adding behaviors to Mecanim states directory. Open the Example.unity scene there and play the game. If you play the game, you can press the space bar to change the states in the Animator Controller attached to the Controller game object. The cycle starts in the NoBehaviors state—this is simply an empty state with no additional behavior. If we press the space bar, we transition to Light1Random. This state changes the color of the Light1 light in the scene. If we press the space bar again, the state will change to WaitAndSwitch. This state waits for a given time and switches to the next state: Light2Random. This one changes the color of the Light2 light. If we press the space bar again, we will transition to the RotateObject state, which rotates an object visible in the scene. Pressing the space bar yet again transitions the controller to the Light1Random state again. See the following screenshot for reference:

Finished controller
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.36.38