This system implements a Binary Space Partitioning (BSP) algorithm to generate procedural 2D dungeons in Unity 2022. The solution features recursive space division and intelligent connection strategies to create highly playable dungeon layouts.
-
🧩 Initializes from a rectangular bounding box
-
✂️ Recursively divides space using binary splitting
-
🎲 Randomly selects split axis (horizontal/vertical) and position
-
⏹️ Termination condition: subspace reaches preset room size threshold
-
🌳 Constructs complete binary tree data structure
-
🔢 Assigns unique identifiers to each leaf node
-
🚪 Leaf nodes correspond to final room units
-
🏗️ Maintains complete tree topology
-
📐 Records spatial boundary information for each node
-
🔗 Establishes parent-child and sibling connections
-
🛣️ Implements bottom-up traversal strategy
-
🤝 Creates shortest path connections between adjacent spaces
-
📏 Dynamically adjusts corridor width parameters
-
🧱 8-direction neighborhood detection
-
🔢 Bitmask-based wall calculation
-
📐 Automatic wall texture angle matching
All art assets are legally licensed: Dungeon Asset Pack by Pixel Poem
🛠️ Tech Stack
Unity 2022 | C# | BSP Algorithm | Procedural Generation
📅 Version Info
v1.0 | Last Updated: November 2023
👨💻 Developer
guobarou
💡 Ideal for Roguelike, RPG and other games requiring procedural map generation
