Tutorial 3: Combining World and Dungeon
In this advanced tutorial, we will use the Dungeon Generator Node to "inject" a structured dungeon into a procedurally generated world.
The Goal
We want a large organic world (like a forest or cave) that contains several structured dungeons (like ancient ruins) tucked away inside it.
Step 1: Set Up the Base World
Start with a graph similar to the one created in Tutorial 1.
- Open your
CaveGraph. - Ensure you have a base terrain output (e.g., a "Ground" channel).
Step 2: Pick Dungeon Locations
We need to decide where the dungeons should go.
- Add a Poisson Sampler node.
- Adjust the
Minimum Distanceso you don't have too many dungeons too close together. - This node will output a Point List.
Space for Screenshot: Poisson Sampler node settings.
Step 3: Add the Dungeon Generator Node
- Add a Dungeon Generator Node.
- Connect the Point List from the Poisson Sampler to the
Pointsinput. - In the node inspector:
- Assign your
SimpleDungeonFlow(from Tutorial 2). - Add your Room Templates to the library.
- Assign your
Step 4: Blending the Results
This is the most important step. We need to make sure the world "makes room" for the dungeon.
- Take the Reserved Mask output from the Dungeon Generator Node. This is a 1.0 value wherever a dungeon room exists.
- Add a Math Node (Set to
Subtract).- Input A: Your base world noise.
- Input B: The Reserved Mask.
- This "carves" a hole in your natural terrain where the dungeon is located, preventing walls from overlapping with your rooms.
Space for Screenshot: The graph layout showing the subtraction logic using the Reserved Mask.
Step 5: Final Output
- Connect the Logical ID output of the Dungeon Generator node to a Logical ID Overlay node to merge it with your world IDs.
- Connect the Placements output of the Dungeon node to your terminal Tilemap Output node.
- Click Generate on your scene's
WorldGeneratorobject.
Result
You should now see a vast procedural landscape with perfectly integrated, hand-crafted dungeons spawned at semi-random intervals!
Space for Screenshot: A high-level view of a procedural world with a structured dungeon ruin integrated into the terrain.