- Home /
Random Room Generator
Hello!
I would like to create a script that allows the map to be created randomly everytime you play it, but I have no idea how I can code it.
The script will use prefabs to create the rooms. You have to create the prefabs and put them in your assets. Then you can set the amount of rooms you can have. Like 2 dead end rooms, 5 hallways and 1 ending. The map will be created once the game is started. To make so the rooms connect, you have to set a emptry game object at each side where you want a new room to be created. The empty game object have to clip in the end of the side. This is head to explain but there us a picture lower down on the page. The thing I just said doesn't really have to be done. Only in the worst cases. I think there would be a easier way to do this. The rooms will then randomly get created with the brefabs and it will try and avoid to clip trough another room.
That is how I want a script to work but I have no idea how to script it so if you would know, pleas etell me! :)
I suggest you put some more details about this problem and you might get some good answers. If all the room prefab pieces are the same size you may be able to do some sorta simple math to position each new piece.
Not sure how you intend to wall off the area though. Will you be detecting the end points of the random generation and create a wall to close the room ins$$anonymous$$d of adding more pieces? The empty game objects on the end could be useful for something like that but might not be necessary depending on how you size everything and keep track of all the locations.
Did you ever get anywhere with this? I have a similar need.
Hey, I ended up getting DunGen from the assets store and that works really well.
Your answer
Follow this Question
Related Questions
Help with Generating Random Tiles 1 Answer
Random Button / Plane Generation. 0 Answers
random generated room system -1 Answers