- Home /
Procedural generation of dungeons with rooms made in the new tile map system?
Good evening!
I need to procedurally generate dungeons for a project of mine (think Zelda Link to the Past but with randomly generated dungeons only) now my approach to that is planned to be some form of grammar system to be able to generate "missions" in forms of keys needed for doors etc within the dungeon, but that itself should be of less matter to my question.
What I wonder is how I would go about to be able to merge rooms that I've made in the new tile map system together? As it is now I can easily paint a whole dungeon and play it through, but I thought that I should paint a room each and then somehow merge them together into one dungeon fittingly.
Due to the lack of resources on tile maps I am quite at a loss how this could be achieved, if it's even possible. I'd be really grateful for all forms of ideas and help on this as it's quite crucial for the project.
Worst case scenario is to abandon Unitys tile maps, but since they're pretty handy that would be a shame to have to do.
Hello!
What a great idea for a project! However, it is not clear to me what your question is: what is it that you need from the Tile$$anonymous$$ap system, or what is the functionality you are missing?
If you are asking how should the algorithm work that connects the rooms, why not generate logical connections, and then create tiles that follow those connections? In general, that's how dungeons are generated: you create the rooms, then you connect the rooms.
Hey! I'm sorry for being unclear about my question, thanks a lot for taking your time to invest yourself in my clumsy situation.
I have discovered that you can relatively easy make prefabs out of tilemaps and instantiate them as any other gameobject. The only trickery on that part seems to be to make sure that they all have compressed boundaries so origin etc makes sense with each other.
But to make my question more clear. How would one go about to know if there's an opening/entrance/door etc in the tilemap to know that this is a place where a new room is needed.
$$anonymous$$y initial thought was to make some form of empty game object to denote "doorway" or something and use that as spawn points, but it feels like there might be better solutions to it. It's not completely clear to me how to know what vector3 to give the room when getting spawned so that it ends up at a sensible place.
You are welcome, it is an interesting topic! :)
So if I understand your question, you want to know how to deter$$anonymous$$e what part of the dungeon needs to be connected?
In this case, I still think that generating a model first, and then generating the actual dungeon that is an implementation of that model (I do the same with a 3D, room based environment, and it works quite well).
For example, you deter$$anonymous$$e how many rooms you want, and then start generating from there. The first room will always need to have at least one exit, and most of the rooms should have at least 2 exits (except if your dungeon is really small), but slowly decrease the number of branches as you approach the desired room number. You can even directly specify for each exit when generating them, which room it shall be connected to (in the end your dungeon will be a planar graph, which has restrictions on how many "corridors" it can have).
A good example to look at is The Binding of Isaac. You could also look into the maze generation algorithms, particularly I was thinking that Prim's algorithm is something similar. I hope this helps, and feel free to ask more questions!
P.S: this Unity tutorial might also be useful for you.
Your answer
![](https://koobas.hobune.stream/wayback/20220612152552im_/https://answers.unity.com/themes/thub/images/avi.jpg)