Skip to main content
Version: Next (dev)

Time of Day and Weather

The Time Of Day component (plTimeOfDayComponent) gives a world a clock and a weather. Everything it plays back comes from one Environment asset: where and when the scene is, and a timeline over the 24 hours of the day that keys exposure, sun and moon, sky, fog, clouds, wind, rain and snow. The day repeats every 24 hours. Rain builds up wetness and snowfall builds up snow cover over in-game hours. For gameplay, scripts blend in named weather overrides (a storm for a mission, fog for a cutscene) and clear them again.

The component renders nothing itself. It writes the properties of the scene's Sun Position, Directional Light, Sky Atmosphere, Sky Light, a global Post Process Volume, Fog, Volumetric Fog, Volumetric Clouds, Simple Wind and Snow components, and the global weather. Most values are multipliers or offsets on what the scene authored, so one Environment works in many scenes. When the Environment stops driving a system, or the component is removed, every property gets its authored value back.

Concepts​

Clock. The clock counts local hours from 00:00 of the Environment's date. It only runs while the game runs (Play the Game or Simulate). In the editor the scene shows its start time; the Time of Day slider in the scene toolbar previews other times without changing the scene.

Stepped sun. The sun moves in small steps (by default 0.4°, at most every 2 s) instead of a little every frame. Each step stays inside the virtual shadow map's rotation tolerance and lasts longer than its settle time, so the shadow pages keep rendering while time runs. Setting the time moves the sun at once. Days shorter than about 19 minutes make each step larger than the tolerance.

Sun and moon. Both Sun Position components follow the same clock. While the sun is below MoonShadowElevation (by default −4°), and both lights were authored with shadows on, the moon light casts the shadow instead of the sun light. The authored shadow settings come back when the clock releases the lights.

Timeline weather. Without an override, the weather is the timeline's: its cloud, fog, wind, sun, rain and snow tracks at the current clock time.

Weather overrides. An override replaces the timeline's weather values until it is cleared. Each channel changes over its own part of the transition: clouds and wind lead, the light follows when the clouds are overhead, fog follows, rain and snow come last. A new transition starts from the weather as it is, so changing your mind halfway does not jump, and clearing an override blends back to the timeline as it is by then. While the clouds change, the new clouds arrive as a front: a band that crosses the sky with the clouds' wind, from beyond the render distance upwind until it has passed overhead.

Wetness and snow cover. Rain raises wetness quickly and the ground dries slowly in sun after the rain stops. Snow cover works the same way, with a slower melt. Both run on in-game hours, so skipping time dries the ground.

Systems found or created. On the first frame the component looks for each system the Environment drives. With CreateMissingSystems on, a missing sun, moon, sky atmosphere, sky light, exposure volume, fog, volumetric clouds or wind is created on a child object named Environment Systems, which is never saved. Volumetric fog and snow cost GPU time and need scene setup, so they are only driven when the scene already has them.

Setting up​

  1. Add a Time Of Day component (category Lighting) to any object. Use one per scene.
  2. Set Environment to Data/Base/Environment/Temperate.plEnvironmentAsset, or to your own copy of it (see Environment Asset).
  3. Set StartTime. Leave StartWeather empty to follow the timeline, or enter the name of an override to start in it.
  4. Look at the systems list at the top of the component's properties. Each system shows Found on and the object's name, Created when the scene runs, Missing; not driven, or (for volumetric fog and snow) Not in the scene; left out. Click Add missing to scene to create those systems as real objects (one undo step), so that you can edit them, for example the sun's intensity.
  5. Volumetric clouds are off by default: enable them with Rendering.VolumetricClouds.Enabled or a Post Process Volume (see Volumetric Clouds). Exposure changes need cameras in Auto exposure.
  6. Press Play. With the default 24-minute day, one real minute is one in-game hour.

Properties of an object with a Time Of Day component: the Systems list saying which systems were found and which are created when the scene runs, the Add missing to scene button, and the Environment, Clock and Sun and Moon groups with Environment set to Temperate

Time Of Day component​

PropertyDefaultDescription
EnvironmentnoneThe Environment asset. Without one only the clock, the sun and the moon run, from the component's own date and location properties.
StartWeatheremptyName of an override to start in. Empty follows the timeline.
CreateMissingSystemsOnCreates the driven systems the scene does not have when it starts.
ExposureVolumeautoPost Process Volume that receives the exposure changes, if not the first global one.
StartTime12 hLocal time at which the clock starts, 0 to 24.
StartPausedOffThe clock holds until a script unpauses it.
DriveSunAndMoonOnThe clock drives the Sun Position components.
Sun, MoonautoObjects with the Sun Position components, if not the first sun and the first moon in the scene.
SunStepAngle0.4°The sun moves once it is this far from the direction it was last drawn at. 0 to 10°.
SunStepInterval2 sMinimum time between two sun steps.
MoonShadowElevation−4°Sun elevation below which the moon casts the shadow. −18° to 10°.

Without an Environment the component shows its own Year, Month, Day (2026-06-21), DayLength (24 min), Latitude (51.5°), Longitude, UtcOffset and NorthOffset. With an Environment these are hidden and the Environment's location and date are used. StartWeather, CreateMissingSystems and ExposureVolume only apply with an Environment.

A Sun Position component that the clock drives shows its time and location read-only. Switch off DriveSunAndMoon to edit them by hand.

Previewing in the editor​

The scene toolbar's Time of Day slider previews any time of the day, in 15-minute steps, without changing the scene.

  • The track is a strip of the scene's day: night, twilight and daylight come from the sun's height at the scene's location and date. Blue marks where the Environment's timeline rains and white where it snows. Ticks mark 06:00, 12:00 and 18:00.
  • The readout shows the previewed time as HH:MM with the weather at that time, for example 10:30 Rain. The leftmost position shows Scene and the start time: the scene's own state.
  • Show Scene Time, next to the slider, returns to the scene's own time. Set As Start Time writes the previewed time into the component's StartTime as one undo step.
  • The slider and the Environment window's playhead share the previewed time, so moving one moves the other.

Scene > Lighting > Weather Preview switches the viewport to any of the Environment's overrides, or back to Timeline, without changing the scene.

Scripting​

Functions on the Time Of Day component, available from AngelScript, C# and Visual Script:

FunctionDescription
SetTimeOfDay(Hours), GetTimeOfDay()Set or read the local time on the current day.
SkipToTime(Hours, Seconds)Run the clock forward to the next occurrence of a time over that many real seconds. 0 snaps.
SetClockPaused(Paused), IsClockPaused()Pause and resume the clock.
SetRuntimeDayLength(Minutes), GetRuntimeDayLength()Change the day length for this run.
SetDate(Year, Month, Day), GetDayNumber()Move to a date; days since the start date.
GetSunElevation(), IsNight()The sun's elevation in degrees; whether it is below the horizon.
SetWeather(Name, Seconds)Blend in one of the Environment's overrides. 0 snaps, a negative time uses the override's own TransitionTime. Timeline clears the override.
ClearWeather(Seconds)Return to the timeline's weather. A negative time uses the Environment's ReturnTime.
GetWeather(), GetTargetWeather(), GetTransitionProgress()The current weather (Timeline or an override's name), the weather it is turning into, and how far the transition is.
GetWetness(), GetSnowCover(), GetWindSpeed(), GetPrecipitation()Surface and weather state for gameplay and audio.

The component sends event messages to its own object:

  • plMsgTimeOfDayEvent with the event type (Sunrise, Sunset, Hour, Midnight), the hour and the day. It is only sent while time passes on the clock; setting the time sends none.
  • plMsgWeatherChanged with From, To, Duration and whether the transition started or finished.

Console variables​

CVarDefaultDescription
Environment.FreezefalseStops the clock.
Environment.TimeOverride-1Pins the time of day to this local hour (0 to 24). −1 lets the clock run. The toolbar slider uses it.
Environment.DayLength-1Overrides the day length in real minutes. −1 uses the scene's.
Environment.WeatheremptySwitches to one of the Environment's overrides at once. Empty or Timeline returns to the timeline. The Weather Preview menu uses it.

See CVars for how to set them.

Troubleshooting​

ProblemCause and fix
The sun does not moveThe game is not running, StartPaused is on, or Environment.Freeze is set. In the editor, use the Time of Day slider.
Shadows switch to cascades while time runsThe day is shorter than about 19 minutes, so each sun step exceeds the virtual shadow map's tolerance. Lengthen the day or reduce SunStepInterval.
Exposure does not changeThe cameras are not in Auto exposure.
Clouds do not changeVolumetric clouds are off by default. Enable Rendering.VolumetricClouds.Enabled or turn them on in a Post Process Volume.
A system shows "Missing; not driven"CreateMissingSystems is off, or the component has no Environment.
The created sun is too bright or too dimCreated systems use default values. Use Add missing to scene and edit the new objects.
A Sun Position component's time and location are greyed outThe scene's Time Of Day component drives it. Switch off DriveSunAndMoon to edit them.
"The Weather component is deprecated" in the logThe scene still has the old global Weather component. See below.

Migrating from the Weather component​

The global Weather component (plWeatherComponent) is deprecated. The Time Of Day component and its Environment replace it: rain and snow are keyed on the Environment's timeline (the Rain and Snow categories), and scripts blend in its weather overrides. For local weather, such as a blizzard on a mountain top or a dry interior, use Weather Volumes.

Old scenes still load. The component no longer appears in the Add Component menu, and an existing one shows a read-only Deprecated note in its properties. When one activates, it logs a warning once and migrates what it cheaply can, but only while no Time Of Day component drives the weather:

  • Its WeatherProfile becomes the global weather.
  • In data saved by the old component, its textures, the CPU rain's shape and the weather pass switches become the weather's render settings.

Its other values are read and dropped: the direct rain and snow values, the surface look, the lens look and the cloud biases. The global weather no longer takes a weather profile; timeline rain and snow replace it.

To migrate a scene by hand:

  1. Add a Time Of Day component and set its Environment, for example to a copy of Data/Base/Environment/Temperate.plEnvironmentAsset.
  2. Key the rain and snow on the Environment's timeline. Put the old textures into the Environment window's Constants panel.
  3. Delete the Weather component.

See also​

In this section​