Creating a Day/Night cycle

If we are creating an open world title or any kind of game where the player is outdoors, one thing that would be nice is the ability to have our world change the time of day at the same rate.

Getting ready

Before we start working, we should have a level created with a Sky_Sphere and a directional light (the default map has this). To be sure, you can use the DayNightCycle-Before map from the example code folder.

How to do it…

Perform the following steps to create a day/night cycle:

  1. As we discussed before, we can use Directional Lights to act like the sun. For our day/night cycle we will want our lighting to change over time, so let's select the DirectionalLightStationary object from the Scene Outliner tab and then from the ...

Get Unreal Engine: Game Development from A to Z 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.