Building the Bunker
Hey there! We thought today is a good day for something else. Lets talk tech. About the dungeon generation in Bunker Björn. Procgen a topic sought after by many and we can contribute a quick tour through our minimalistic approach to the problem.
Preparations
First thing to do was consider what we wanted and how fast we could get it on the dancefloor. There is a plethora of ways to facilitate a procedural world generation. Tilesets, voxel based world generation, modules … there’s more.
The fastest in terms of “getting it done” seemed to be the module based approach. As such, Bunker Björns dungeons are comprised of a fixed set of modular rooms, that are then pieced together randomly. They would be attached at connector points and ideally that would yield more or less seamless dungeon layouts.
The idea is simple but the devil’s in the details. He always is.
Rooms
With that idea in mind, we prepared a number of rooms.
According to aforementioned specs, we outfitted the rooms with some connector points. The dungeon generator would pick a start room and create branches with the modules in random directions, effectively forming the dungeon. The dungeon tree. It has the downside that you can’t create loops with this. That means a branch cannot lead back to its origin. But it was great anyway. Until it wasn’t.
Making space
The modules, of course, had no concept of occupied space so the generator would place them even though they would be overlapping each other. It made for some really interesting contraptions but didn’t do much in terms of playable space. The way these modules were created in the first place, didn’t lend itself to a grid system, which would have helped us to determine occupied space. With connector points being at arbitrary points in space it was impossible to make the thing align to a world-space grid.
The solution was bounding boxes. It’s a little crude. But it most definitely solves the problem of overlapping modules. Before placing each module down, the generator now checks, if there are other module bounds intersecting the new one. And if that’s the case, it doesn’t place the module.
Performance
Now that modules can be placed correctly without overlap, another problem occured. Framerates would be dropping in higher levels. Maybe that is a non-issue because ultimately there won’t be 20 stages to the end (yes we’re planning to have an actual end to this game). However, it still felt like we needed to make this scalable. We had to cull the modules somehow. Good thing we decided to use module bounds earlier!
From the start this looked very much like something that we could use to ensure only relevant modules were active and only actors within active modules would get ticked. We just had to find the module the player was currently in, enable the modules around it and disable all the others and their actors within.
It was necessary to create a datastructure that would allow quick and easdy access to the dungeon tree. The branches mentioned earlier. We would previously just discard this because there was no need for this data at game-time. But it was basically already there so we just kept it and ka-pow. Module culling.
Random Sprinkles
Now that this was all running, it was time to breathe life into the bunker. Artificial robot life. This was a rather easy task we just sprinkled the module prefabs with spawn points for enemies and props. As icing on the cake we added a random-light system. You might have noticed it. There are coloured lights here and there.
After a room has been placed, a randomiser function is called on it, which randomly places props and decides which lights stay on and in what colour.
Enemies are spawned in two different ways. At first, a fixed number of enemies is spawned along the dominant path to the exit to ensure that you will face at least some stuff to shoot at, that’s also shooting back at you.
Additionally, new enemies are always spawned in modules that become active, that are the furthest away from the player. This is tied to a certain proximity rule so that their numbers don’t grow all too much.
And that was the quick tour through how we generate a bunker. We hope you liked iit. If you’re down here, you either scrolled all kinds of fast or actually read through. Either way. thanks for reading!
If you have questions about this, do leave us a comment!
Cheers!
Get Bunker Björn
Bunker Björn
Status | In development |
Author | Game Kombinat |
Genre | Action |
Tags | 3D, Dungeon Crawler, Low-poly, Ludum Dare 48, Pixel Art, Procedural Generation, Sci-fi, Singleplayer, Unity |
More posts
- The ReBunkered UpdateJun 25, 2021
- The Pickups UpdateMay 17, 2021
- The Shooty UpdateMay 12, 2021
- Post Jam work on Bunker BjörnMay 09, 2021
Leave a comment
Log in with itch.io to leave a comment.