Hi there, I’m quite new here, have been using unity for a week and loving it so far. I wanted to make procedurally generated levels for my first game, but after searching a bit couldn’t find a solution already made that pleased me. Found some scripts generating Square rooms with corridors between them, ( Like this tutorial and this tutorial ) but I was looking to do something more cave-like.
So, I set on a quest to create my own. I started by following the logic on this roguebasin article implementing the suggestions of the article in the C# example they had there. Then used some pieces of wisdom from the other 2 tutorials I had found to do the spawning of objects and to fill the unconnected islands that escaped the creation logic.
Now, I’m a hobbyist programmer, which means my code is probably way too messy for your taste, and there are also probably way better ways to do this than what I’m doing. But I wanted to share what I did to help the next newbie that comes like me looking for a solution like this.
So, here is a webplayer of my result and the unity package:
I’ve made it so it picks some spots around the map and places some premades there. That could be enemy spawners, decoration, goals, etc. It also picks 2 spots on corners for prefabs of the Player and a Door to next cave. It picks the door spot on the farthest corner it can find from the player. It also picks corners and spawn prefabs that could be treasures. You can choose how far apart those prefabs should be, so it won’t spawn 2 enemy spawners too close to each other.
It still has some rough edges and things I need to fix (and gets quite confused if you go too high on Wall Percentage), but it’s working well enough for now
Hope this helps someone somewhere, now back to working on the rest of the game can’t wait to play my game on these levels.