3D Dungeon Generation System in GDAU

Jun 29, 2024

3D Dungeon Generation System in GDAU

Overview

  • Project: 3D dungeon generation system inspired by 'Lethal Company'
  • Purpose: Create randomized and explorable 3D dungeons
  • Technique: Uses prefab rooms connected with corridors

Initial Approach

  • Started with a 2D version of the problem
    • Spawn rooms of different sizes
    • Detect and handle overlapping rooms:
      • Push overlapping rooms apart based on their centers of mass
      • Iterate until rooms are separated
    • If all rooms fail to separate, run the algorithm multiple times with different placements

Connecting the Rooms

  • Pathfinding Algorithm: Connect doors (green=necessary, yellow=optional)
  • Reachability: Ensure all rooms are reachable
    • Avoid isolated rooms
  • Union-Find Algorithm: Maintain connected components (trees of nodes)
    • Connect nodes by updating their root to the lowest value in the new tree
    • Keep a list of rooms and floors needing connections

Transition to 3D

  • Similar approach as in 2D:
    • Place and separate rooms in 3D
    • Connect rooms with corridors
    • Add stairs to connect multiple floors
  • Ensure all floors are connected using Union-Find algorithm

Practical Implementation in GDAU

  • Dungeon Kit Prefab Scenes: Define various room types
    • Rooms have doors (required or optional)
    • Prefab scenes set initial placements
  • Dungeon Generator Instance: Preview and generate dungeons in levels
    • Uses the described algorithm to spawn rooms and their connections
  • 3D Models: Example dungeon created using free 3D model sets
    • Modular design with different room types (corridor, stair, trap, treasure, etc.)

Conclusion

  • System allows for quick customization and integration into games
  • Example GitHub repository available for use

Additional Details

  • Preview Scene: Shows size and shape of the dungeon
  • Customization: Swap out dungeon kits for different games
  • Practical Use: Creates visually appealing and explorable mazes

Next Steps

  • Explore the GitHub repository and experiment with the add-on
  • Customize rooms and dungeon kits for specific game requirements

Resources

  • GitHub Repo: [Link provided in the video]
  • Questions: Leave comments for further clarification