Update #96: Procedural Dungeon Decoration

This week Nic and I dive into how the 3D dungeons are coming along, and specifically how the game AI will decorate and display rooms based on Theme and Purpose.

But first, new programmer Daniel has finished his unity training with the Zenva course Discover Unity Game Development. If you are interested in learning Unity this is a good place to start. I reviewed each lesson with Daniel as he completed them and it really did teach him the fundamentals. It took about 80hrs to do them all (about 40hrs of video, 40hrs of doing). Archmage is a big-ish project in Unity with a lot of advanced Unity UI stuff created by Nic. I think this course prepares people well to work on real projects.


When I created the 2D dungeons in Archmage it just threw random crap on the screen. It was a purely random dungeon room generator. I wanted to fix this to provide a sense of place and purpose, a story if you will, of the dungeon. But how?

When I started working on redoing the dungeons I invested in trying to distill the essence of the dungeon crawl. What makes a dungeon interesting? What are the characteristics to each scene that are memorable? Fortunately superfan Brindor recommended this excellent book:

What I like about this book is it is light on rules/system and heavy on ideas and thoughts. I don’t care about specific rules for asphyxiation, but I am interested in the ideas behind it!

Using this book I was able to discern each dungeon needs a reason for existing: to hold something, protect something, to service something. Once you know that reason it suddenly becomes clearer what rooms should be in a dungeon, and which ones shouldn’t. If humanoids are to live there, there must be a place for food storage, source of water, sleeping quarters. If the place is designed to hold some ancient evil or super valuable artifact or off limits knowledge, it will be trapped and have lots of locked doors.

I embarked on the 3D dungeons just seeing if i could make a room, any room. Once the structure and lighting were in place I started putting stuff inside it. Unfortunately it looked exactly like what it was: random crap in a room.

How do I signify a room’s purpose? I found this map sparked my imagination:

While the rooms are unlabeled they have a visual language that communicates what kind of room and therefore experience the player can expect in there. There are very few props in each area, yet the ones there tell all that need to be told.

Now, what system would enable room purpose, something that could define the props allowed to be shown? It is complicated because while a bed is clearly in a sleeping area, what about a desk? It could be in a bedroom or a study. What about a chest? It could be in a barracks, a treasure room, or a study. We came up with a tagging system. Each prop can be tagged with the kind of purposes it can fulfill. There are some problems with this and I may have to solve this differently soon, but for now that is the solution we have and will pursue it until it tells us otherwise.

One major complication (pain-in-the-ass) is some objects can be placed anywhere, but not all. So a table and chairs looks pretty good pretty much anywhere and orientation doesn’t matter. Even if multiple tables and chairs are in the same room that they don’t align to any set pattern doesn’t seem to matter, it looks organic.


But beds? Beds look terrible this way. Cupboards? Cupboards look awful unless they are up against a wall, and not too close to a corner or door. This has necessitated creating layout objects that know how to lay themselves out. Ultimately it is a sophisticated and highly reusable system, just not something I intended to make.

Bad! Bad beds!

Bad! Bad beds!

Good! Good beds!

Good! Good beds!

Getting objects to lay themselves out in patterns is necessary for structural things like columns. If there is just one column, it can be anywhere in the room and look ok. But as soon as there are two or more, they must be laid out equidistant from each other or a nearby wall. It is this “pattern” code developed for columns that I plan to use for beds and whatever else comes up (benches in a chapel, tables in a classroom towards a lectern).

It’s been a long time coming, but I’m pretty close to the end now on this dungeon stuff. Once the tech is all working right I can continue making content, getting textures, lighting, and props that all work together instead of the placeholder stuff I’ve been using.

BBQ Bomb was right, these 3d dungeons are a rabbit hole. But I think the results are better this way and I’ll be proud of it. Sometimes when I code there are points where I say “wow, this is terrible, i’ll never use this system again” and sometimes it is immediately clear the system is good and can be reused for multiple purposes. This is how i feel about this system. It will work for Archmage Rises and beyond.