Course contentsShow
← Unreal Engine Game Development
Lesson 838 of 88012. World Building and DeploymentFree lesson

Streaming Non-Static Actors with Data Layers

Implement logic to stream dynamic actors and interactive props based on their assigned Data Layer visibility and proximity.

In this lesson, you will learn how to trigger the loading and unloading of dynamic, non-static actors by toggling their associated Data Layers based on player proximity.

The Core Concept

While World Partition handles static environment geometry automatically, non-static actors—such as interactive loot boxes, roaming NPCs, or destructible props—often require manual control to optimize memory. By assigning these actors to specific Data Layers, we can leverage the UDataLayerManager to change their visibility state at runtime. Instead of keeping a complex prop active globally, we toggle its Data Layer "On" only when the player enters a defined spatial trigger volume, and "Off" when they exit.

Implementing Proximity-Based Streaming

To manage these actors, you should utilize a TriggerVolume paired with the SetDataLayerRuntimeState function. This allows the game to load the actor’s blueprint logic and mesh data only when necessary, effectively "streaming" it into existence.

Here is a conceptual look at how you might toggle a Data Layer via C++ within an actor overlap event:

// Within your Trigger Volume logic
void AStreamingVolume::NotifyActorBeginOverlap(AActor* OtherActor)
{
    if (OtherActor && OtherActor->IsA(APlayerController::StaticClass()))
    {
        UDataLayerManager* DLManager = GetWorld()->GetDataLayerManager();
        if (DLManager)
        {
            // Set the target Data Layer to Activated
            DLManager->SetDataLayerRuntimeState(TargetDataLayerHandle, EDataLayerRuntimeState::Activated);
        }
    }
}

Why This Matters for Dynamic Content

When you set a Data Layer to Activated, Unreal Engine performs a runtime load of the associated actors. When set to Unloaded, the engine flushes these actors from memory. For non-static actors, this is critical because it prevents the CPU from processing ticking logic, complex animation blueprints, or physics calculations for actors that are nowhere near the player. By decoupling these objects from the persistent world and placing them into reactive Data Layers, you maintain a leaner memory footprint and preserve CPU cycles for actors within the player's immediate field of interaction.

Key Takeaway: Use Runtime Data Layer state changes to stream non-static actors into memory only when player proximity dictates their presence, preventing unnecessary performance overhead from inactive, complex dynamic objects.