Devlog 3 - Procedural Dungeons (Part 1)


With this update, the player can now explore procedural generated dungeons, populated with random enemies and traps. There’s a lot to improve here, but so far I have a dungeon generator that can generate linear dungeons following a small set of rules.

I’ve been wanting to learn how to make procedural content for a while now, and I came up with Enfabler to do that. The first month or so of development has been focused on the basic mechanics and combat and now they’re in a state I’m fairly happy with for now. I’ve been watching GDCs on procedurally generating content (PCG) for a while and found a method that I thought was a good starting point to learn PCG.

The method I decided to use was using generative grammars combined with tiles to generate entire dungeons that follow a set of rules. These rules ensure that you won’t get dungeons that have the same type of room 3 times in a row and get too repetitive and that some rooms, like healing rooms, get evenly spread through the dungeon.

The dungeon is assembled like a sentence, but each word contains information about the kind of rooms that are generated, so a generated dungeon would be generated looking something like this Start > Encounter > Trap > Treasure > Healing . Boss > End. There are rules applied to make the dungeon make sense; it must start with the Start room and end with the Healing > Boss > End rooms, rooms cannot be used twice in a row, there are minimums and maximums for how many times each room can be used and healing rooms in larger dungeons will be generated at regular intervals.

Once this basic dungeon data is generated, the generator uses tiles to make the actual rooms. These are Unity prefabs that contain the assets for a blank room with nothing inside and are set up with spawners for enemies, traps and objects. There are various tiles, each representing different room shapes and the generator will stitch these tiles together to create a full dungeon and then spawn objects inside the rooms depending on the type of room. For example, most rooms spawn in a few enemies but encounter rooms spawn in a lot more, using a budget system that ensures the enemies spawned in are not too strong or numerous.

Traps and objects use a layermask to determine which object spawners they can spawn from. For example, When trying to spawn a painting, the rooms will check for available spaces with the “WallSpawner” layer and then spawn the object on an available space. This means I can make a greater variety of objects and spawn them at specific places like walls, corners or besides doors. This is also how tables only spawn near the center of the room.

I’ve made a good start on this system but there’s a lot of improvements I plan to make, such as adding treasure and puzzle rooms. Also, while this method is relatively easy to implement compared to some of the other methods, it can only generate linear dungeons, which are not as interesting to explore. I plan to add tiles that can add side rooms to improve exploration but that may be much further in development. Additionally, I want to change how objects spawn in as they look to cluttered and regular.

Files

Enfabler 0.1.2.zip 64 MB
Nov 03, 2023

Get Enfabler

Leave a comment

Log in with itch.io to leave a comment.