In this recipe, we will create a simple day and night cycle animation using the Animation View.
We are going to create this recipe from scratch in Unity, so we don't need any additional assets. You can also use the provided example Unity project and go to the Chapter 07 Special effects\Recipe 10 Creating a day and night cycle with the animation window
directory. You will find an Example.unity
scene there.
Open it and play the game to see the effect.
Simple day and night cycle
To create a day and night cycle with the Animation View, follow these steps:
- Create an empty game object and call it
DayAndNight
. - Create another empty game object, call it
SunAndMoonPivot
, and parent it to theDayAndNight
game object. - Create two more game objects,
SunPivot
andMoonPivot
, and parent them toSunAndMoonPivot
. - Then create the
Sun
andMoon
objects and parent the first one toSunPivot
and the second one toMoonPivot
. - Lastly, create...