Don’t like your day? make it go fast — A guide to controlling day-night cycle in Unreal Engine 5

Madara Premawardhana
3 min readNov 9, 2023
Photo by ANIRUDH on Unsplash

Before we begin, you need to have a good understanding on how lighting is controlled in a basic Unreal Engine environment and what changed from Unreal engine 4 to 5.

In Unreal Engine 4 (UE4), creating a day-night cycle was typically controlled using a combination of Blueprints and the Level Blueprint. Here are the basic steps on how to set up a day-night cycle in UE4:

Directional Light: You would typically use a Directional Light as your primary light source. The Directional Light represents the sun in the scene.

Blueprints and Timeline: To control the time of day, you would often use a Timeline in a Blueprint. Timelines allow you to interpolate between different values over time.

Sun Rotation: In the Timeline, you would set keyframes for the rotation of the Directional Light to simulate the movement of the sun across the sky. For example, you would gradually rotate the light from east to west to simulate the sun’s movement during the day.

Sky Material and Atmospheric Effects: To achieve realistic changes in the sky’s appearance, you might use a sky material that adjusts its parameters (e.g., color, intensity, and cloud cover) based on the time of day. You can also use atmospheric effects to simulate changes in the atmosphere and lighting conditions as the day progresses.

Post-Process Effects: You can apply post-process effects to adjust the overall color grading, bloom, and other visual effects to match the time of day and create a more convincing day-night cycle.

Level Blueprint: To control the day-night cycle globally across your level, you can use the Level Blueprint. You can trigger events in response to the timeline’s progress and use them to set the time of day or control other game-related aspects.

The SunSky system in Unreal Engine 5 is responsible for rendering the sky, sun, atmosphere, and lighting effects within a scene. It offers advanced features for simulating the behavior of natural light, the sun’s position, atmospheric effects, and their interaction with the environment. This system helps in creating realistic day-night cycles, dynamic weather conditions, and immersive outdoor environments by simulating the scattering of light in the atmosphere, which affects the color and appearance of the sky. It is more like a combination of a above elements simplified and developed to make developers lives easier.

Now on how to make a fast moving day-night cycle.

Follow these steps in a blueprint actor’s event graph..

  1. Access the SunSky actor and via Get actor of class function.
  2. From the return value, get the directional light which is attached to your SunSky.
  3. Delta seconds in Tick event figures the natural rythem of your gameplay. We need to multiply this by a constant value which figures out how much you want to speedup your day. We will be multiplying the delta seconds in event tick by the constant we set for speed.
  4. Then you need to make a vector which takes the rotation of your directional light. This is because the Pitch of 3D world or Y values figures out the motion of the sun in Azimuth.
  5. Now you need to assign the new vector’s return value to Local rotation of the target — directional light.

Now important points:

Don’t set it to the world rotation as it does not consider the sun’s relatively.

Make sure you have SunSky actor in your level. Haha a rookie mistake!

At last drag and drop your blueprint to the level and give an evil laugh!

--

--

Madara Premawardhana

PhD Student at the University of Buckingham, School of Computing