How to do it...

To blend animations (colors in this example) of a game object, you need to follow these steps:

  1. Open the scene and select the light game object in the Hierarchy.
  2. With the light selected, go to Window | Animation to open the Animation View and create at least two animations the same way as in the Using Animation View to create a flickering light recipe, but this time set the color property instead of the light's intensity. In our example, we have two Animation Clips: Day and Night. They just set the color of the directional light: Day sets it to bright yellow and Night to dark blue. There is no change in the light color over time. Each animation has two key frames with the exact same color value in each key frame (this color is different for each animation). Each animation lasts for about 7 seconds.
  3. An Animator Controller will be created automatically.
  1. Open the Animator Controller and create two transitions between our animations, one going from Day to Night and one from Night to Day, as shown in the following screenshot:
  1. Those animations are looped, so you can set the Transition Duration to around 5 seconds to make the effect more subtle. You can set the Transition Duration in the Settings foldout in the Inspector after you select the transition.
  2. Make sure that the Has Exit Time option is selected as we do not use any other conditions in this example. You can also add your own conditions and use scripts to trigger them.
  3. Play the game to see the effect.
..................Content has been hidden....................

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