World environment

The day-night cycle, water queries, buoyancy and swimming, and loading streaming regions and data layers from gameplay.

Last updated Oct 31, 2026Edit this pageVersion 1.0.0

Terrain, water, foliage and sky are authored in the editor; see World building and Rendering. This page covers what gameplay code does with them at runtime.

Day and night

A DayNight component drives the sun, sky and night lighting from a time of day. DayNightComponent

FieldDefaultEffect
timeOfDay12Hours, 0 to 24
animate, dayLengthSecondsoff, 120Advance the clock; a full day takes this many real seconds
azimuthDegrees0Compass direction of the sun's path; any angle from -180 to 360 turns the whole arc around the vertical axis
sunIntensity, nightIntensity1.4, 0.02Sun light by day and night
skyDayIntensity, skyNightIntensity1.0, 0.15Sky light by day and night

NPC schedules read the same clock; see AI crowds and director.

Water

Place water with AWaterActor; its MWaterComponent describes the body. A WaterZone component bounds which bodies take part and fills the horizon past them. WaterZoneComponent

MWaterStatics answers water questions at any point, from C++ or Visual Scripting: MWaterStatics

FunctionReturns
IsUnderwater(point), HasWaterAt(point)Whether a point is under or over water
GetWaterHeightAt, GetWaterDepthAt, GetWaterFlowAtSurface height including waves, depth and river flow
GetNearestShorePoint, GetDistanceToShoreThe shore
SampleWaterAt then GetLastWaterHeight, GetLastWaterNormal, GetLastWaveHeight and the other GetLast... functionsEverything about one point from a single query

Buoyancy and swimming

Add a Buoyancy component to a dynamic rigid body to make it float: strength, sampleRadius, maxDepth, and linearDrag and angularDrag while in the water. BuoyancyComponent

Characters switch to swimming on their own when the water reaches their chest; see Character movement.

Streaming regions and data layers

In an open world, levels stream by cells around the player. Gameplay can also load parts by hand through MLevelStatics: MLevelStatics

FunctionEffect
LoadStreamingRegion(name), UnloadStreamingRegion(name), IsStreamingRegionLoaded(name)Keep a named region loaded, for example ahead of a cutscene or a fast-travel destination
SetDataLayerActive(name, active), IsDataLayerActive(name)Switch a data layer, such as a story state of a village, on or off

MLevelStatics also reads and writes scene environment settings by key, such as fog and ambient color: GetSceneFloat, SetSceneFloat, GetSceneVector, SetSceneVector, GetSceneBool and SetSceneBool.

Engine sources

This page describes behavior implemented in these files of the engine repository, checked against commit 7c4a1b166.

  • Engine/Source/Runtime/Game/Public/Game/Components/DayNightComponent.h
  • Engine/Source/Runtime/Game/Public/Terrain/DayNightSystem.h
  • Engine/Source/Runtime/Game/Public/Game/MWaterStatics.h
  • Engine/Source/Runtime/Game/Public/Game/MWaterComponent.h
  • Engine/Source/Runtime/Game/Public/Game/AWaterActor.h
  • Engine/Source/Runtime/Game/Public/Game/Components/WaterZoneComponent.h
  • Engine/Source/Runtime/Game/Public/Game/Components/BuoyancyComponent.h
  • Engine/Source/Runtime/Game/Public/Water/BuoyancySystem.h
  • Engine/Source/Runtime/Game/Public/Water/CharacterWaterSystem.h
  • Engine/Source/Runtime/Game/Public/Game/MLevelStatics.h
  • Engine/Source/Runtime/Game/Public/Scene/LevelDataLayers.h

Page feedback

Was this page helpful?