Recipe 3: World Partition Open World Setup
This recipe demonstrates how to set up persistence across a massive open world powered by Unreal Engine's World Partition system. It covers streaming cell lifecycle management, harvestable resource nodes, and defeating enemy camps without respawning.
1. The Challenge of Open World Streaming
In an open world with World Partition:
- A world can span kilometers and contain 10,000+ external actors.
- Actors are constantly created and destroyed as grid cells stream in and out around the player.
- If a player destroys an enemy camp in Cell (X=2, Y=5), walks 2 kilometers away, and later returns, the camp must stay destroyed without respawning full-health enemies or closed loot chests.
2. Recipe Components
[World Partition Map]
├── Placed Harvestable Tree / Rock Node (BP_HarvestableResource)
├── Placed Outpost Enemies (BP_EnemyCampBandit)
└── Player Character with Streaming Source (76,800 unit reach)3. Step 1: Persistent Harvestable Resource Node
Create a harvestable tree or mining node that remembers when it has been mined:
Blueprint: BP_HarvestableResource
- Add a
StaticMeshComponentfor the rock/tree and aStaticMeshComponentfor the broken stump/rubble. - Add the
UAegisPersistenceComponent(Scope = World). - Add variables with SaveGame ticked:
bIsHarvested(Boolean)RemainingHarvests(Integer, default 3)
Harvesting Logic
[Event: OnHitWithPickaxe]
│
▼
[Decrement RemainingHarvests]
│
▼
[Branch: RemainingHarvests <= 0?]
├── False ──► [Play Chipping FX] ──► [Mark Changed (Aegis)]
└── True ──► [Set bIsHarvested = true]
[Hide Rock Mesh / Show Rubble Mesh]
[Spawn Resource Items in World]
[Mark Changed (Aegis)]Visual Restoration on Stream-In
When the cell streams into memory, restore the mesh appearance immediately in BeginPlay:
[Event BeginPlay]
│
▼
[Branch: bIsHarvested == true?]
├── True ──► [Hide Rock Mesh / Show Rubble Mesh] (Was already harvested)
└── False ──► [Show Rock Mesh / Hide Rubble Mesh] (Still pristine)4. Step 2: Persistent Enemy Camps (Tombstoning)
When placing bandit camps across World Partition:
1. Attach UAegisPersistenceComponent
Attach the component directly to your placed enemy actor Blueprint (BP_Bandit).
2. Guard Death in EndPlay
When the player defeats the bandit in combat, call DestroyActor(). Aegis automatically marks a tombstone in the in-memory record store.
Inside BP_Bandit's Event End Play:
[Event End Play]
│
▼
[Was Destroyed By Load (Aegis)]
│
▼
[Branch]
├── True ──► (Do nothing; enemy was already killed in previous session)
└── False ──► [Spawn Death Ragdoll]
[Award Player Bounty XP]
[Play Death Sound]3. What Happens on Cell Stream-Out and Return?
- The player kills the bandit. The actor is destroyed and leaves a tombstone.
- The player runs far away. The cell streams out of memory.
- The player runs back into the area. The cell streams in from the map package.
- Before the first tick (
AC-303), Aegis matches the placed actor's identity against the tombstone and removes the enemy before they can attack or animate!
5. Step 3: Configuring Streaming Ranges
World Partition streaming ranges dictate how far around the player cells are loaded:
- In Unreal Editor, open World Settings.
- Under World Partition Setup → Runtime Partitions → MainLayer:
- Cell Size: Set appropriately for your world scale (e.g.
12,800or25,200units). - Loading Range: The distance cells stream in around the player (e.g.
76,800units = 768 meters).
- Cell Size: Set appropriately for your world scale (e.g.
- Verify that your Player Controller has
bEnableStreamingSource = true.
6. Optimization for 10,000+ Actor Worlds
In an open world with 10,000 placed persistent actors, walking all 10,000 actors on every autosave would be wasteful.
Follow the State Revision pattern:
- In your resource nodes and chests, implement
IAegisPersistenceEvents::GetAegisStateRevision. - Return an integer revision counter that only increments when harvested or interacted with.
- Aegis will skip inspecting all 9,990 untouched actors in microseconds, keeping autosaves strictly under 1.0 ms!
Next Steps
- Learn how to spawn dynamic actors during play in Dynamic Runtime Spawning.
- Review empirical performance data in Benchmarks & Reproduction.