# 6. Open-World Level Design Tests and Pitfalls Part of [[Open-World Streaming]]. Previous: [[5. Floating Origin]]. ## 6.1 Design first: sightlines set the radius [[Level Up! (Review)]] treats **landmarks** as the main way players find their way: a tower, a mountain, a glowing tree they can steer toward from anywhere. Streaming fights that. If the tower is in a cell three cells away, it doesn't exist yet. So decide in this order: 1. **List the landmarks** and the distance each must be visible from (the "can I see the castle from the village" test). 2. **Put landmarks in the bootstrap scene as low-detail stand-ins.** A 200-triangle silhouette of the castle with a matte material, always loaded. When the castle's cell loads, swap it for the real model, or just let the real one draw in front. 3. **Pick `cellSize × loadRadius` to cover gameplay distance, not view distance.** You need detail where the player can *interact*: combat range, pickup range, the travel distance during a worst-case load (part 1). Everything beyond that is stand-ins, fog and skybox. 4. **Pace between points of interest.** Level Up!'s advice to keep the player moving toward the next reward applies here: a cell with nothing in it is a cell where the player gets bored. Use the cell grid as a design sheet and mark which cells have a point of interest. If too many are empty, the cells are too small or the world is too big. ## 6.2 Quest and mobile - **Memory is the real budget.** With radius 1 you hold 9 cells, plus up to 16 more in the hysteresis ring that haven't unloaded yet: up to **25 cells** worst case. Budget per-cell memory as "total budget ÷ 25", not "÷ 9". - Start Quest with smaller radius values, or a tighter hysteresis gap, as a quality tier ([[Scalability and Quality Tiers]]). - Keep `maxConcurrentLoads = 1` on Quest. Storage is fast, but the main-thread integration is the bottleneck. - **Threshold.** For VR, use a smaller floating-origin threshold (for example 500 m). Hand-tracking and controller jitter shows up sooner than on a flat screen. Expect a shift to be invisible as long as nothing caches world positions. Test it with the scene below. ## 6.3 Lighting with additive scenes (from the docs, not tested here) - Only the **active scene's** Lighting settings (skybox, ambient, fog) apply. Keep the bootstrap scene active with `SceneManager.SetActiveScene` and let cells contribute only lightmaps and local lights. - Each cell can bake its own lightmaps. Bake cells with the same lighting settings and the same directional light, or the borders won't match. - **Light probes** from additively loaded scenes need the probe tetrahedralization rebuilt after a load or unload. The Light Probes manual describes `LightProbes.TetrahedralizeAsync()` for this. Call it after a batch of cell changes, not after every single one. - Realtime GI and occlusion culling data are per-scene. Occlusion across cells is generally weak. Rely on distance culling and the stand-ins. ## 6.4 Tests The planner tests ran as a .NET 10 console program on 2026-12-01 (12/12 passed). Here they are as Unity Test Framework EditMode tests (type-checked only; see [[Unity Test Framework]] for the asmdef setup): ```csharp // Assets/Tests/EditMode/WorldGridTests.cs using System; using System.Collections.Generic; using System.Linq; using NUnit.Framework; public class WorldGridTests { static readonly CellCoord Origin = new CellCoord(0, 0); [Test] public void NegativeCoordinatesFloor() { Assert.AreEqual(new CellCoord(-1, 0), WorldGrid.CellAt(-0.001, 255.999, 256)); Assert.AreEqual(new CellCoord(3906, -3907), WorldGrid.CellAt(1_000_000.5, -1_000_000.5, 256)); } [Test] public void LoadsNearestFirst() { var toLoad = new List<CellCoord>(); var toUnload = new List<CellCoord>(); WorldGrid.Plan(Origin, 1, 2, new HashSet<CellCoord>(), null, toLoad, toUnload); Assert.AreEqual(9, toLoad.Count); Assert.AreEqual(Origin, toLoad[0]); Assert.IsTrue(toLoad.Skip(1).All(c => WorldGrid.Distance(c, Origin) == 1)); } [Test] public void HysteresisPreventsThrash() { var resident = new HashSet<CellCoord>(); var toLoad = new List<CellCoord>(); var toUnload = new List<CellCoord>(); WorldGrid.Plan(Origin, 1, 2, resident, null, toLoad, toUnload); resident.UnionWith(toLoad); WorldGrid.Plan(new CellCoord(1, 0), 1, 2, resident, null, toLoad, toUnload); Assert.AreEqual(3, toLoad.Count); Assert.AreEqual(0, toUnload.Count); resident.UnionWith(toLoad); WorldGrid.Plan(Origin, 1, 2, resident, null, toLoad, toUnload); Assert.AreEqual(0, toLoad.Count); Assert.AreEqual(0, toUnload.Count); } [Test] public void FarJumpUnloadsEverythingBeyondUnloadRadius() { var resident = new HashSet<CellCoord>(); for (var x = -1; x <= 2; x++) for (var z = -1; z <= 1; z++) resident.Add(new CellCoord(x, z)); var toLoad = new List<CellCoord>(); var toUnload = new List<CellCoord>(); WorldGrid.Plan(new CellCoord(3, 0), 1, 2, resident, null, toLoad, toUnload); Assert.AreEqual(6, toUnload.Count); Assert.IsTrue(toUnload.All(c => c.X <= 0)); } [Test] public void ExistsFilterSkipsEmptyCells() { Func<CellCoord, bool> island = c => Math.Abs(c.X) <= 1 && Math.Abs(c.Z) <= 1; var toLoad = new List<CellCoord>(); WorldGrid.Plan(new CellCoord(1, 1), 1, 2, new HashSet<CellCoord>(), island, toLoad, new List<CellCoord>()); Assert.AreEqual(4, toLoad.Count); } [Test] public void UnloadRadiusBelowLoadRadiusThrows() { Assert.Throws<ArgumentException>(() => WorldGrid.Plan(Origin, 2, 1, new HashSet<CellCoord>(), null, new List<CellCoord>(), new List<CellCoord>())); } } ``` Console run output: ```text PASS origin is cell 0_0 PASS negative coords floor, not truncate PASS far coordinates stay exact in double PASS radius 1 loads 9 cells, own cell first PASS then the ring at distance 1 PASS step east: load the new east column only PASS step east: hysteresis keeps the west column (distance 2 <= unloadRadius) PASS step back west: nothing loads or unloads (no thrash) PASS jump to x=3: columns x=-1 and x=0 (distance 4 and 3 > 2) unload PASS exists filter: corner of a 3x3 island loads only 4 cells PASS unload < load throws PASS scene naming convention ALL PASS ``` ### Manual test scene for the origin shift Make `World_ShiftTest` with a world-space particle trail, a TrailRenderer on the player, a NavMeshAgent following the player, a Cinemachine follow camera, a Rigidbody stack and a world-space triplanar material. Set the threshold to 50 m and drive in a circle. Every shift should be invisible. Anything that pops goes in the part 5 table. ## 6.5 Pitfalls | Symptom | Cause | Fix | |---|---|---| | Content missing in a strip along x = 0 or z = 0 | `(int)` truncation instead of `Floor` | `WorldGrid.CellAt` (part 2) | | Cells load and unload over and over at a border | No hysteresis | `unloadRadius > loadRadius` | | Hitch every time a cell appears | Heavy `Awake`/`OnEnable` in the cell, or too many concurrent loads | Spread setup over frames; `maxConcurrentLoads` 1–2; `backgroundLoadingPriority` Low | | Exception unloading a cell | Unloading while it's still loading | Unload only after `IsLoaded`/`Failed` (the streamer retries) | | Cell appears 1 km away from where it belongs | Loaded after a shift and not placed | Always go through `FloatingOrigin.Place` | | Cell moves twice as far as everything else | Shifted by the origin *and* placed | Only `Place`d scenes are managed (part 5) | | NPC vanishes when its home cell unloads | It's still a child of that scene | Keep it in the bootstrap scene or `MoveGameObjectToScene` | | Chest re-closes when you return | State stored on the cell's objects | Store it in a registry or save data outside the cell | | Addressables cell never loads | Missing label, or the address isn't simplified to `World_x_z` | Check the group entry; the label is the source of truth | | Memory climbs with build-list cells | Assets only those cells used are never freed | `Resources.UnloadUnusedAssets()` at a calm moment, or move to Addressables | | Lighting changes when a cell becomes active | A cell became the active scene | Keep the bootstrap scene active | | Jittery hands, wobbling car at 10+ km | No floating origin | Part 5 | | Particles or trails streak after a shift | World-space effects | `FloatingOriginFixups` |