In October of 2014 I created my Randomized Dungeon System. After release it turned out to be flawed with bugs. Recently I discovered the level instance feature of UE4 and decided to try it again from scratch. I came up with a new generator which still uses tiles compared to other generators which are only able to use walls and floors on a fixed grid. Since I’ve gained a lot of experience in the meantime, this new version should be much cleaner, more stable and more professional. It is still made completely with blueprints.
You can use it in commercial and non-commercial projects and are not required to give credit to me.
- Each tile is a separate level. It can contain anything a regular level can.
- Performance friendly by having an automated system of hierarchical instanced static meshes implemented.
- Connections can go in all directions (not limited to a grid).
- TileCondition and LayoutModifier classes exist to modify the layout during the generation process (create child classes and assign them to the tiles)
- Tiles can have limited amounts so unique or rare tiles only spawn a couple of times at most.
- Tiles will only spawn where they don’t intersect with “WorldStatic” collisions.
- Actors exist to help with the tile setup process.
- No seeds/random streams implemented right now.
- Only one generator can exist in a level.
- Spawning the levels after layouting the tiles is performance intense and takes a while.
- No replication for multiplayer.
The generator works in two phases: layouting and spawning. First the layout is set up by spawning DungeonTile actors in the level and connecting them. Afterwards the DungeonTile actors spawn their assigned levels before getting destroyed as they are only placeholders.
There are three examples included in the project. The first one is a dungeon made of hallways. It shows that there can be multiple types of connections (“narrow” and “wide” in this case) and that actors placed inside level tiles and navigation works fine.
The second example consists of hexagonal tiles as you see them in many strategy games. They use the connections “G” and “W” (Ground and Water) at the edges to generate natural looking landmasses (compared to tiles which are either completely ground or water). It’s also best for showing the difference between the “From Center”-mode turned on and off. When turned on, the generator will add the next tile to the one that is closest to the level’s origin, leaving no gaps in this example.
The third example has a train track raging in all directions with twists and turns. The fact that connections can be rotated and therefore generate twisted layouts is what this example is supposed to display.
At this point I have no video detailing the exact procedure of using this generator, but here’s a quick rundown:
Create levels which you want to use as tiles.
Place TileConnection actors in it at the points where it should connect to another tile (red arrow towards next tile). Enter a keyword in their properties to indicate the type of connection it uses.
Place a DungeonTileHelper actor in it (it will automatically move itself to the level’s origin) and fill out the TileData information (the connection information is automatically gathered from the TileConnection actors).
Rightclick the TileData structure variable from the DungeonTileHelper and copy it.
Create a new DataTable asset (Miscellaneous > Data Table) for the “TileEntry” structure. Create an entry and paste the copied TileData into it.
Repeat this for all the tiles you need.
Create a new DataTable asset for the “ConnectionMatch” structure. Add one entry for each type of connection your tiles have and add the types of connections it can connect to to the array.
Create a new level and place the DungeonGenerator actor in it.
Setup the Generator’s properties (read the tooltips!).
Place at least one DungeonTile actor in the scene and enter the name of a row of the data table you created to turn it into the associated tile.
Start playing or simulating the level.
Add all levels used for tiles to the packaging settings in the project settings. Otherwise they will not be packaged and missing from the final game.
If you did everything correctly, a dungeon/level should be generated. If not, read the tooltips of each property, study the examples and ask questions in this thread. I’ll try to create a video later but that might take a few weeks as my job is demanding and I only have the energy to work on something during weekends.