How to do it...

To use behaviors with Mecanim states, follow these steps:

  1. First we need to prepare the example scene. Create a Cube in the scene.
  2. Create two lights and name them Light1 and Light2. Place them near the cube so you can see their effect.
  3. Create an empty game object and name it Controller.
  4. Create a new Animator Controller and name it LogicController.
  5. Add an Animator component to the Controller game object and assign the LogicController to it.
  6. Open the LogicController.
  7. Create an empty state and name it NoBehaviors. Make it the default state.
  8. Create a Trigger parameter and name it Switch.
  9. Create four empty states and name them Light1RandomWaitAndSwitchLight2Random, and RotateObject.
  1. Create the following listed transitions. ...

Get Unity 5.x Animation Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.