U
tab 04World & Game Loop7 lessons — tap to open
07 / 07 · 22 min
World & Game Loop★ exercise

Exercise: it becomes a game

your project so far▸ Arena.unity

everything from tab 01–04 · a run you can win or lose

exercise3–4 h

Turn the arena into a place, then into a game. Sculpt terrain around the blocks you have been fighting on, bake the light, scatter a few hundred trees, add ambient sound — then wire up three waves, a defeat screen and a restart button. It must still hold 60 FPS.

what you reuse

Terrain sculpt + layersBaked lightmapsSkybox + fogPrefab variantsPropScatter + raycastLOD + batchingAudio mixerGameDirector waves
animated diagram

The same arena, now somewhere worth fighting in — and something you can actually lose.

Build it in five passes

Pass 1 — grey blockout

Before a single texture: sculpt the shape and walk the character around it. If the space is not interesting in grey, no amount of trees will fix it.

  • Terrain 200 × 200 m, heightmap resolution 513, positioned at -100, -0.05, -100.

  • Use Set Height to flatten a clearing about 40 × 40 m around the existing block grid — do not move the blocks, build the world around them.

  • Raise hills around the edges so the player cannot see the terrain border.

  • Smooth everything twice. Spiky terrain is the number one giveaway of a first scene.

Pass 2 — materials and modular pieces

  • Four terrain layers maximum: grass, dirt path, rock on the slopes, and one accent.

  • Tiling 10–15 m per layer so the repeat is not obvious.

  • Build a hut from 6 modules on a 1 m grid: floor, wall, wall-with-door, corner, roof, step.

  • Make two prefab variants of the wall — stone and wood — so the hut and a ruin share one base.

Pass 3 — scatter, do not place

run PropScatter from the component's right-click menu
Trees        count 180   radius 80   scaleRange 0.85 – 1.35   groundMask = Terrain
Rocks        count  90   radius 70   scaleRange 0.6  – 1.8    groundMask = Terrain
Grass tufts  count 260   radius 45   scaleRange 0.8  – 1.2    groundMask = Terrain

// the slope check in PropScatter is what keeps trees off cliff faces
if (Vector3.Angle(hit.normal, Vector3.up) > 30f) continue;

Pass 4 — light it

  • Directional light at 50, -30, 0, Mode = Mixed, soft shadows, intensity ~1.1, slightly warm.

  • Mark every tree, rock and hut piece as Static. The Knight and the enemies stay dynamic.

  • Bake at Lightmap Resolution 10 first to check the look, then once at 30 for the final. Window▸Rendering▸Lighting.

  • Fog matching the skybox horizon, linear, start 90 m end 150 m — then drop the camera Far to 160.

Pass 5 — sound and optimisation

  • A 2D ambience bed (wind + birds), one 3D source at the hut (a fire), footsteps via Animation Events.

  • LOD Group on the tree prefab with two levels plus a Culled band.

  • Enable GPU Instancing on the tree, rock and grass materials.

  • Shadow Distance 40 in Quality settings. Then open the Profiler and check you actually hit the targets below.

Done when

  • ✓You can walk the Knight from the hut to the tree line without hitting an invisible wall or falling through.
  • ✓Nowhere in the scene can you see the edge of the terrain or a horizon seam.
  • ✓Shadows are baked on the static props and realtime only on the character.
  • ✓No two trees are the exact same size and rotation.
  • ✓No tree or rock is floating above the ground or half buried in a cliff face.
  • ✓Ambience plays everywhere; the fire at the hut gets quieter as you walk away.
  • ✓The Stats panel meets every number in the table below, measured while walking, not standing still.

Numbers to hit

MetricTargetWhy
Batches≤ 100This is the number that kills mobile first.
Triangles on screen≤ 300kAbove this a mid-range GPU starts dropping frames.
Realtime lights1Everything else must be baked. No exceptions.
Shadow distance≤ 50 mRealtime shadows are usually the most expensive thing in the scene.
Camera far plane≤ 200 mFog hides the cut, and you get the performance for free.
FPS while walking≥ 60Standing still proves nothing — measure in motion.

If you want more

bonus 1

Add the day-night cycle script and rebake nothing — see which parts break and why.

bonus 2

Bake a NavMesh and make one enemy walk a patrol route between the trees.

bonus 3

Add a river with a scrolling UV water shader and a 3D water sound.

bonus 4

Build a night variant of the arena, using the same props and a different light setup.