Dungeon Generator
Dungeon Creater Tool
Technical Design
Introduction & Development Objective
My goal for this project was to create a customizable procedural dungeon with creative choices as well as elements of randomness to create a different experience every time, similar to a rogue-like experience.
Summary
Solo Projects
6 weeks half-time (4hours/day)
Made using Unreal Engine 5.6
Generated Dungeons
Without Chunks
Generated with 10 rooms
Generated with 20 rooms
With Grid
Generated with 10 rooms
Generated with 20 rooms
WALKTHROUGH
Features
customaztion of the dungeon
The tool offers variers different ways to customize how the dungeons layout will be as well as what will generate inside the variers rooms. The user can increase or decrease the chances of sertent things to spawn or remove them completely.
Options of custimization
With just small adjustments the dungeon will be generated in a completely unique way, making each experience different from any previous experiences.
Selection of rooms to be generated inside the dungeon
How many rooms the dungeon will have
The maximum of time it would take to generate the dungeon
If the generation will be random or a special seed
How many items, enemies and special items shall spawn in the dungeon
How big the area of the dungeon should be
If there will be another area and how big that area shall be
How many tries the dungeon has to place a room before restarting
Use Chunks
Functionality
Functionality
The dungeon generation system was built around a “Master Room” actor that contained the core elements needed for the rooms.
The Master Room held empty folders for Geometry, Exits, Items, and Enemy Spawn Points, which helped organize each room’s components. The BluePrint contained only a Box Collider to detect room overlapping during generation and an Arrow Component for debugging purposes and to show the direction the room would spawn.
I could duplicate the Master Room and start to build the first rooms of the dungeon. With placing objects in the folders I could creat spawn points for the verias things I wanted to spawn in next. In the script I could randomly select one of this spawn points to get its location for where the next room was going to spawn.
Once a spawn point got selected and spawned a room, I removed it from the potential spawn point list so it would not spawn another room on the same spawn point.
With each new room spawning they also have a list of spawn points that gets added to the random selection of where the next room will spawn.
Once the desired amount of rooms have spawned, enemys and items will spawn in a smilar way. The spawn points will be selected at random and will generate enemys and items from a pre made list of options.
Script Showcase
Master Room
Test Room 1
Spawn Points:
Green Arrow - Room spawn
Black point - Enemy spawn
White point - Item spawn
Early Stage
After I got the tool to successfully generate a functional dungeon with basic shaped rooms, I started to create my own modular kit in Blender to see how it generates a dungeon with nonsymmetrical rooms.
In the early stages I used basic shaped rooms to see if it the script was capable of generating a rough dungeon. With using this basic shaped rooms I also could easly see if something went wrong in the generation. With this shapes all the rooms should line up with each other if all went correctly.
Problems
One thing I started to notice was the pure randomnes that the dungeon generated. There was no way to decide in what derections or how the order of the rooms was going to be. The only thing at this stage I could influence in the generation was the likelihood of what room will spawning.
The first way to solve this problem was to seperate the rooms to different categorise. I made several list that the dungeon could choose from like: basic rooms, corridors, stairs, special rooms and others.
With having these seperated list I made it so depending on how many rooms there was left to genreate the genreator would choose from a different list of rooms.
Unfortunately this made the generation not so modular and very depeneded on the dungeons size.
It was then I got told about wave function collapse, so I decided to look more into how wave funaction collapse works and how I could implement it in my dungeon generation.
Wave function Collapse
Wave Function Collapse is a procedural generation algorithm to create complex and coherent layout with only a small amount of input samples or a set of rules it has to follow.
For this project I wanted the function to follow a set of more complexed rules then just choosing from a list. I also wanted to make it editable before the generation to the dungeon more
Chunk
Grid Functionality
Once I manged to create a good grid for the generation I needed to make the rooms only spawn inside the chunks.
Room generation with the grid
I tried several diffrent ways to get the rooms to spawn in the chunks correctly. The best solution I found this far was to check if a room overlapped with a chunk, if they did a boolen node called “Chunk Check” would turn to true. This would allow the room to stay and the script would continue, it would also turn back Chunk Check to false to test the next room that would generate.
If a room would not overlap the Chunk Check would stay as false and the room would be deleted and the generation would try again.
I started by creating a box collider big enought to fit one of my test rooms and called it a Chunk.
Grid’s generation
I added a event in the begining of the dungeon generation to make the chunks spawn in rows and collums to create a grid.
generation exampel
BluePrint: Chunk check
Generated Grid
Grid Fetures
Now when I was able to spawn in rooms correctly in the grid I wanted to give the grid more functionality. (to make it as a wave function collapse)
By making the chunks have different boolen checks on them I can decide what kind of rooms will spawn on those chunks.
I made the generation that only the “corridor room” was able to spawn on the “corner chunk”. If any other room would spawn, it would get deleted and the generator would try again. I also added after a “corridor room” was generated on a “corner chunk” all the rest of the “corner chunks” would get deleted.
I started by making the edge of the grid into “Corner Chunks” with the use of Line traces and boolen checks.
Each Chunk sends out 4 Line traces facing: X, -X, Y and -Y. If a line trace hits another chunk it will turn a boolen check to True depending from what derection it came from. By being on the edge of the grid, at least one of this boolen checks will stay as False.
If not all of the boolen checks has turned to True the chunk will be turned into a “Corner Chunk”.
The last thing I did with this project was the option to add a secondary gird that spawned in at the chosen “corner chunk” location.
With this feature a whole new dungeon can be generated on the secound grid. Completely different rooms can be selected in this grid, givning the option to add a new area.
Reflection
I accomplished many of my personal goals and my main goal, to create an customizable procedural dungeon and I am proud of the resolut.
In the beginning of this project I had no idea what I was getting myself into and how endless this project can be. There is hundred, if not thousand of more features that could be implemented in this tool to make the dungeon generation more customizable as well as random.
One challenge that has bothered me early on in this project that I was never able to complete is to generate loops in the dungeon. To make the the generation sense when their is a adjacent room next to another and place a door connecting them. I spent a bit to much time to try make this feature work. If I could go back I would completely ignore this challange and focus more customizable ways to generate the dungeon.
I have learned so many new things from scripting this tool and I will continue working on this tool and add more features and ways to customize the dungeons generation
I accomplished many of my personal goals during this project, including my main objective: creating a customizable procedural dungeon generator. I am proud of the result.
I accomplished many of my personal goals during this project, including my main objective: creating a customizable procedural dungeon generator. I am proud of the result.
At the start of the project, I didn’t fully understand its scope or how complex it would become. There are hundreds, if not thousands, of additional features that could be added to make the dungeon generation more customizable and random.
One challenge that troubled me early on was generating loops within the dungeon—ensuring that adjacent rooms connect logically with doors. I spent too much time trying to make this feature work, and ultimately, I was unable to complete it. If I could go back, I would focus less on this challenge and instead prioritize adding more customization options to the dungeon generation.
Throughout this project, I have learned a great deal about scripting and procedural design. I plan to continue developing this tool, adding new features and expanding the ways users can customize the dungeon generation.
Thank you for reading!