Skip to main content

World Generator Documentation

The World Generator is a node-based procedural generation tool designed to create rich, varied environments. It translates high-level noise and logic into physical Unity Tilemaps and Prefab placements.

Key Concepts

1. Tilemap World Graph

The "brain" of the generator. A Tilemap World Graph is a node graph asset where you define your generation logic.

  • Nodes: The individual operations (e.g., Perlin Noise, Threshold, Math).

2. Port Types

Nodes communicate via typed ports. Each data type (Channel) is represented by a specific colour in the graph:

IconTypeDescription
FloatContinuous values (0.0 to 1.0). Used for noise, gradients, and weight maps.
IntDiscrete values (0, 1, 2...). Primarily used for Logical IDs and Biome IDs.
Bool MaskBinary data (True/False). Defines filled vs empty areas or logical conditions.
Point ListA collection of X, Y coordinates. Used for scattering objects and spawning prefabs.
PlacementsComplex data structures containing prefab references, rotation, and scale.

3. Biomes

A BiomeAsset defines how Logical IDs are translated into actual Unity tiles.

  • Maps a name (e.g., "Wall") and an ID (e.g., 2) to a set of tiles.
  • Allows the same generation logic (the graph) to look completely different (e.g., a "Cave" biome vs a "Forest" biome).

4. Execution Pipeline

The generator runs in a specific sequence:

  1. Compilation: The graph is converted into an efficient execution plan.
  2. Execution: Nodes run in order, often using multi-threaded Unity Jobs for performance.
  3. Snapshot: The result is captured in a WorldSnapshot.
  4. Output: The snapshot is written to scene Tilemaps and Prefabs are instantiated.

Workflow

Step 1: Create a Biome

  1. Create a BiomeAsset in your project.
  2. Define your mappings for common Logical IDs like Floor (1) and Wall (2).
  3. Assign tiles or RuleTiles to each entry.

Step 2: Author the Graph

  1. Create a Tilemap World Graph asset (Create > Dynamic Dungeon > Tilemap World Generator > Tilemap World Graph).
  2. Open the Tilemap World Graph Editor window (Tools > Dynamic Dungeon > Tilemap World Generator > Tilemap World Graph Editor).
  3. Assign a Default Biome in the graph's settings panel to enable visual previews of tiles.
  4. Add nodes to create your terrain (e.g., Fractal NoiseThresholdCellular Automata).
  5. Connect your final result to the Output node. (This node is automatically included in every graph and defines which channels are written to the final world snapshot).

Step 3: Set Up the Generator

  1. Right-click in the Hierarchy and select Dynamic Dungeon > Tilemap World Generator > Generator Setup (recommended) or manually add the TilemapWorldGenerator component to a GameObject.
  2. Assign your Graph and Biome.
  3. Configure Layer Definitions (Note: the Generator Setup shortcut handles this automatically for standard configurations).
  4. Click Generate or Bake.

Component Reference: TilemapWorldGenerator

SettingDescription
GraphThe Tilemap World Graph asset to execute.
BiomeThe BiomeAsset used for tile mapping.
World DimensionsThe size of the generation area (Width x Height).
Layer DefinitionsList of Tilemap layers. Each layer links to a port name in the graph.
Seed ModeSwitch between Stable (fixed) and Random (changing).

The Bridge: Dungeon Generator Node

The Dungeon Generator Node is a special node that allows you to integrate the Constraint Generator directly into your World Generator graph.

How it Works

  1. Input: It takes a Point List (the locations where dungeons should start).
  2. Processing: It runs the Constraint Solver internally using a selected Dungeon Flow or Organic Settings.
  3. Outputs:
    • Logical IDs: Emits a channel where the dungeon floor/walls are marked.
    • Prefab Placements: Emits a list of room prefabs to be spawned.
    • Reserved Mask: Emits a bool mask of the entire dungeon footprint.

Typical Bridge Setup

Point GridPoisson SamplerDungeon GeneratorOutput node

You can use the Reserved Mask to "carve out" the dungeon from other terrain. For example, use a Blend Node to ensure that mountains or rivers don't generate where the dungeon has been placed.