Works in Unreal Engine 5.0 to 5.8. Updated November 2026.
Quick answer: set the sun to Movable with Atmosphere Sun Light ticked, then turn it from a Blueprint every tick with Pitch = (6 − Hours) × 15. Add a weak second light as a moon so nights aren’t black.
Step 1: Set up the sky actors
The quickest way is Window > Env. Light Mixer. It has a button for each missing actor. Then check these settings:
| Actor | Setting |
|---|---|
| Directional Light (sun) | Mobility: Movable, Light > Atmosphere Sun Light ticked, Atmosphere Sun Light Index 0 |
| Sky Light | Mobility: Movable, Real Time Capture ticked |
| Sky Atmosphere | Default settings are fine |
| Exponential Height Fog | Optional, but it makes dawn and dusk look much better |
With these set, turning the sun is all it takes. The Sky Atmosphere goes orange at sunset by itself, and the real-time Sky Light picks up the new sky colour.
Step 2: Make the clock Blueprint
- Create a Blueprint Class based on Actor and name it BP_DayNight.
- Add three variables: Hours (Float, default 9), DayLengthMinutes (Float, default 20) and Sun (Directional Light object reference, Instance Editable ticked).
- On Event Tick, add time and wrap it at 24:
Hours = Fmod(Hours + DeltaSeconds * 24 / (DayLengthMinutes * 60), 24)
With a 20-minute day, one real second is 72 in-game seconds.
Step 3: Turn the sun
Still on Event Tick, after the clock:
- Make Rotator: Pitch = (6 − Hours) × 15, Roll = 0. Change Yaw to move where on the horizon the sun rises.
- Set Actor Rotation on Sun with that rotator.
At 06:00 the pitch is 0, so the sun sits on the horizon. At 12:00 it’s −90, pointing straight down. At 18:00 it sets on the other side. Place BP_DayNight in the level, pick your Directional Light in its Sun slot and press Play.
Step 4: Fix black nights
At night the sun is gone, so nothing lights the scene and the sky goes black. Two simple fixes:
- Add a moon. Add a second Directional Light, Movable, with Atmosphere Sun Light ticked and index 1. Give it a low intensity (about 0.3–1 lux) and turn it in the same Tick with Pitch = (18 − Hours) × 15, which keeps it opposite the sun. Turn off Cast Shadows on whichever light is below the horizon, so only one light casts shadows.
- Check exposure. If the night is still too dark or the day too bright, the problem is auto exposure, not the lights. See Unreal Engine 5 Too Dark or Too Bright?
Shadows shimmer or cost a lot while the sun moves? Virtual Shadow Maps redraw when the light turns. Rotate the sun in small steps instead of every frame. For example, only call Set Actor Rotation when the angle has changed by more than 0.05°.
Common problems
| Problem | Fix |
|---|---|
| Sky never changes colour | The sun isn’t an Atmosphere Sun Light, or the level has no Sky Atmosphere |
| Sky colour changes but the ground lighting doesn’t | Sky Light isn’t Movable with Real Time Capture |
| Two suns, or the moon looks like a second sun | Moon is on atmosphere index 0. Set it to 1 |
| Everything black at midnight | Add the moon light, or raise the Sky Light a little at night |
We do this in our Any Weather plugin.
FAQ
Can I start at a specific time?
Yes. Set the Hours default (or make it Instance Editable) to the start hour, for example 18 for sunset.
How do I run code at night, like spawning enemies?
Keep the last whole hour in a variable. When Floor(Hours) differs from it, call an Event Dispatcher such as OnHourChanged. Other Blueprints bind to that.
Will this work in multiplayer?
Not as it is. Each player’s clock runs on its own, so they slowly drift apart. See How to Sync Time of Day and Weather in Multiplayer.