Hi guys, im trying to build a random 2D dungeon generator from diferente premade levels (tilemaps) but im not getting there anyway… im kinda new to scripting and i try find some help but all tutorials and so are or for 3D or to create compact random dungeon maps not to simply randomize premade rooms…
Where are you so far? Can you describe where you are stuck?
Here’s one simple idea that will not generate terribly interesting looking dungeons.
Create your blocks so that they have knowledge of their directions that you have openings to. This could be the typical left to right, up to down, “+”-shape crossing, t-crossing and so on.
Then start from a random or defined location, and get a random block that has at least one direction open. Next, process the directions that are open, and randomize a block to that location that has a matching opening. You have to of course set various rules to get your map water proof. But if you repeat that kind of logic, you would get a dungeon that is random.
This is of course just the logic side of things. Then you would need to build a system that will combine your tile maps together into one tilemap.
I try that method and it word if i use square rooms, with enter and exit center in square size, i just cant get it to connect them properly because i dont have the entrances and exits centered, because my rooms are not square, how can i define the points to conect? Create empty game objects with some kind of name that we use to conect? I cant get it to work anyway… and im a bit newbie… sry for so many and crazy questions
You could just do what I explained, get a room from room Tilemap, then store those as an array, then in your procedural generation script, use these room “blueprints” to create the rooms in your dungeon map.
You’ll eventually have to set tiles manually in code if you are doing procedural dungeon generation.
I don’t know if you can actually somehow merge two Tilemaps (this is what you asked in your other question), correct me if I’m wrong.
To handle the connection points, you would now have room data, where you know that certain tile names are doors, which you can use as attachment points to create edges/connections between rooms (your nodes).