Unity · C# · Procedural Generation Complete

Procedural
Unity World

A world that builds itself at runtime. Pick a map type, size and seed and the game grows chunked Perlin-noise terrain with a height-banded ground shader, L-system trees, evenly spread plants and animals, and a navmesh for the wildlife to roam. Then jump into any animal you can reach, walking, swimming or flying, and eat to keep your points up for the shop.

🎮 Unity ⚡ C# 🏔️ Perlin Terrain 🌿 L-Systems 🎨 Custom Shaders
RoleSolo: I did everything in the game, from the generation, controllers and shop to the shaders, UI and audio
Timeline7 weeks
ContextGame programming degree project, finished and shown in the videos below
01 · Procedural World Generation

🏔️ Systems

  • Chunked terrain: each chunk is a 121 by 121 heightmap built from five octaves of Perlin noise (persistence 0.5, lacunarity 2), driven by a seed, an offset and a scale. A map is 4, 9 or 16 chunks
  • Six map types: Continental, Mediterranean, Highlands, Plains, Large Islands and Small Islands. Each one sets the noise scale, the height thresholds and which chunks get water edges
  • Separate quality settings: the render mesh and the collision mesh each have six detail levels, so you can keep collision cheap while the visible terrain stays dense
  • Height-banded ground shader: sand, rocky ground, ground, grass, mountain body and mountain top are blended by height, using the same thresholds the generator uses. A water plane is sized to the map
  • Navmesh per chunk: every chunk gets its own NavMeshSurface, built one after another once the map is ready, so animals can patrol the generated land
  • Saved maps: seed, offsets, scale, type, size and quality are written to a file per saved map, with points and volume in a separate save

⚙️ Engineering Decisions

01

One set of thresholds for terrain and shader

The height levels that decide where sand, grass and rock start are pushed into the material from the same values the generator uses, so the colours always match the shape of the land, whichever map type is picked.

02

async/await to slice the build

Chunk and mesh generation, placement and navmesh baking are async methods that yield between steps, so the loading screen keeps updating during a build. It spreads work across frames on the main thread. It does not use extra threads.

03

Map settings are data, not scenes

A map is just a seed, an offset, a scale, a type, a size and two quality levels. That is all a save file needs to rebuild the same world.

02 · Algorithmic Placement & Optimisation

🌿 Systems

  • L-system trees: grown from an axiom and rewriting rules over a few iterations, with randomised branch angles, a random bark material and a random leaf type per tree
  • Mitchell's best candidate sampling: for each point, 30 random candidates are tried and the one furthest from every point already placed wins, which spreads trees and animals out without visible clumps
  • Height-aware placement: points are dropped onto the terrain with a raycast and only kept inside the right height band. Land objects stay above the shoreline, water creatures stay below it
  • Distance-based activation: groups of scenery are switched on and off by distance from the player, so far-away objects stop costing update and render time
  • Wandering animals: placed animals patrol random points on the navmesh with a walk animation

⚙️ Engineering Decisions

01

L-systems over prefab variants

A small rule set and a few random ranges give a forest of different trees without hand-authoring dozens of prefabs.

02

Mitchell's over pure random

Pure random placement clusters visibly. Best candidate is simple to write and spreads points well enough for a world built at load time.

03

Cheap rules for what players cannot see

Distance checks switch things off rather than destroying and rebuilding them, which keeps the logic simple at the cost of holding everything in memory.

03 · Player Interaction & Systems

🎮 Systems

  • Swap into any animal: click an animal to see how far away it is, then double-click within range to take it over. The camera follows, its AI switches off and its movement type becomes yours
  • Three movement modes: ground, water and air controllers sit on a shared control-state base, so walking, swimming and flying all read the same input
  • Hunger and points: a hunger bar drains over time, eating food earns points and starving costs them. Food respawns inside a spawn box
  • Shop: spend points on extra animals. Purchases are remembered between sessions and the new animals join the pool that the next generated world is populated from
  • Tutorial prompts: short messages that appear when you first meet a UI element, a food item, an animal you can swap into or a key press

⚙️ Engineering Decisions

01

Interfaces for interaction

Animals, food and shop items implement small interfaces (interactable, edible, buyable), so the player code asks "can I interact with this?" instead of checking for specific types.

02

Control states over one big controller

Each movement mode is its own state with a shared base for jumping, grounding and animation. Swapping animals changes the active state rather than duplicating input code.

03

Events for UI and score

An event manager tells the HUD, the shop and the camera when the map changes or points are spent, so they do not need direct references to each other.

04 · Audio & Music

🔊 Systems

  • In-game music player: previous and next track, a "none" option, pause, a scrubbing slider, a live elapsed and total time readout and the track name
  • Two separate volumes: music and ambience play from their own audio sources, each with its own slider
  • Remembered settings: volumes and the chosen track are saved and restored on the next launch
  • Works while paused: the timer and scrubbing run from Update, because the game's time scale is zero in the pause menu

⚙️ Engineering Decisions

01

Plain audio sources, kept simple

This was a music and ambience player, not an adaptive system. Two audio sources and two sliders covered it. There is no mixer routing or event-driven audio in this project.

02

Where the audio work went next

The adaptive, event-driven side of my audio work lives in Mystic Realms, built on Wwise.

05 · Technology Stack
Unity
Engine, rendering, UI and build
C#
All gameplay and systems scripting
Perlin noise
Terrain heightmaps, five octaves
L-systems
Trees with random bark and leaves
AI Navigation
NavMeshSurface per chunk, wandering animals
Custom Shaders
Height-banded ground and water
async / await
Slicing generation across frames
TextMeshPro
Menus, HUD and tutorial text
06 · Known Limits and Next Steps

🎓 What this project taught me

The whole world is generated up front, so there is no chunk streaming: chunks are not loaded or unloaded as you move, and distance activation only switches things off. Trees are built from many separate objects with their own materials, which is expensive, and saves use an older serialisation approach. I know where the next gains are, and I plan to rebuild the project in Unity 6 with measured before and after numbers for load time and frame rate: awaiting each chunk properly, reusing tree variants, true chunk streaming and a job-based noise step.

Interested in Procedural Systems?

Happy to talk about procedural generation, placement and optimisation in Unity, or how I would build and measure the next version.