Skip to main content

Tutorial 1: Creating Your First World (Procedural Caves)

This tutorial will guide you through creating a simple organic cave system using the World Generator's node-based workflow.

Prerequisites

  • A Unity project with the Dynamic Dungeon tool installed.
  • A 2D Scene with a Grid and Tilemap layers (e.g., "Background", "Ground", "Walls").

Step 1: Create a Biome Asset

Before we generate logic, we need to tell the tool what tiles to use.

  1. Right-click in your Project window: Create > Dynamic Dungeon > Tilemap World Generator > Biome.
  2. Name it CaveBiome.
  3. In the inspector, add two entries:
    • Logical ID 1 (Floor): Assign your cave floor tiles.
    • Logical ID 2 (Wall): Assign your cave wall tiles.

Creating a Biome Asset

Biome Asset setup in the Inspector


Step 2: Create the Generation Graph

  1. Right-click in your Project window: Create > Dynamic Dungeon > Tilemap World Generator > Tilemap World Graph.
  2. Name it CaveGraph.
  3. Double-click it to open the Tilemap World Graph Editor.
  4. Important: Open the graph editor's Graph Settings panel (infromation icon) if not already open and assign your CaveBiome to the Default Biome slot.
    • This is crucial for visual feedback; it allows the editor to use your biome's tile mappings to render a live preview of the graph as you build it.

Creating a Graph Asset

Assigning a Default Biome in the Graph Settings


Step 3: Building the Cave Logic

Inside the Editor, we will chain nodes to create an organic shape.

3a. Generate Noise

Add a Perlin Noise node by right clicking any empty space in the graph editor and select 'Add Node' then 'Noise' then 'Perlin Noise' or press spacebar, type 'Perlin Noise' and press enter. This creates the base "cloud" of values that will become our caves.

  • Adjust the Frequency to around 0.1.

Adding a Perlin Noise node

3b. Threshold the Noise

Add a Threshold node by right clicking any empty space in the graph editor and select 'Add Node' then 'Filter' then 'Threshold' or press spacebar, type 'Threshold' and press enter. Connect the output of the Perlin Noise node to the input of the Threshold node.

  • Set the Threshold value (e.g., 0.4). This converts the fuzzy noise into sharp black-and-white shapes.

Adding a Threshold node

3c. Smooth the Shapes

Add a Cellular Automata node by right clicking any empty space in the graph editor and select 'Add Node' then 'Filter' then 'Cellular Automata' or press spacebar, type 'Cellular Automata' and press enter. Connect the output of the Threshold node to the input of the Cellular Automata node.

  • Set Iterations to 5 and Initial Fill Probability to 0.6. This will remove "speckles" and make the caves look more natural.

Adding a Cellular Automata node

3d. Assign Logical IDs

Add a Bool Mask to Logical ID node by right clicking any empty space in the graph editor and select 'Add Node' then 'Output' then 'Bool Mask to Logical ID' or press spacebar, type 'Bool Mask to Logical ID' and press enter.

  • Connect the Cellular Automata output to the input of the Bool Mask to Logical ID node.
  • Set True ID to 1 (Floor) and False ID to 2 (Wall).

Adding a Bool Mask to Logical ID node

3e. Terminal Output

Connect your final Logical ID result to the Output port on the Terminal Output node (this node is automatically included in every graph). Simply drag a connection to the corresponding port on the Output node to define what tiles will be generated.

Final cave graph


Step 4: Set Up the Scene Generator

  1. In your Unity Scene Hierarchy, right-click and select: Dynamic Dungeon > Tilemap World Generator > Generator Setup.
    • This automatically creates a Grid, Tilemap layers, and the Tilemap World Generator component.
  2. Assign your CaveGraph and CaveBiome in the inspector.
  3. Observe that the Layer Definitions have been automatically populated. The tool links your graph outputs to the corresponding scene Tilemaps (e.g., the "Walls" layer).
  4. Set World Dimensions to 100 x 100.
  5. Click Generate.

Setting up the Scene Generator

The final generated cave in the Unity Scene view