April 22, 2020
This week I’ve been delving into procedural generation of modular structures within the game world. I’ve focused on creating a simple kit for dungeon rooms and corridors, but similarly this kind of system could be adapted to create things like castles, towns or anything that is constructed from modular pieces.
First I created a set of rooms and corridors in Qubicle, a voxel editor, which I then exported, both as a qb (voxels) and also an fbx (polygons). Having the fbx means that I can get a preview of how the model will look as the voxel model only generates at runtime. Therefore I can place other game objects, such as doors, props, spawn locations etc., within the prefab, using the fx as a guide, and they will get populated along with the room.
In order to actually generate the dungeons, I’m using an asset called DunGen.
It’s a really intuitive system for creating modular levels which stitches together room prefabs using door connector objects. Here’s an example room prefab. You can see that there’s a line on the door object which shows the orientation of how it should connect to other room tiles.
Here are some examples of levels generated by DunGen in isolation from the voxel world.
Getting the fbx ‘dummy’version (and by extension the door objects) to line up with the voxel model took some time, but now that I’ve cracked it, I can generate modular dungeons within my voxel world!
Here’s a video showing a procgen dungeon in motion.
So, the basic structure for creating dungeons exists now, but they are currently empty, so next I plan to focus on creating a number of monsters - using the prototype enemies I created previously as a base - that I can then populate dungeons, and the rest of the world with. The modular structure of the dungeons allows for random encounters too (traps, loot spawns etc.) so experimenting with that would be fun too.