Procedurally Generated Room System...

I am working on a procedurally generated system. In my main script, I have an array of GameObjects called Rooms. I also have an int called AllRooms, and it is said to equal the length of the rooms upon start. However, what I need now is how I can access these rooms, and instantiate one after the other. This has puzzled me for a few hours and I cannot think on how I will bring my way around it. Can anyone help me?

Please consider the fact that all my work is in C#

Thanks in advance!

I think I may know what you’re getting at. I’ve written a script for a very similar process. Mine is used to create towers or trees from an array of preconstructed gameobjects. See the script and discussion on it here:

My preconstructed gameobjects are prefabs with an origin (at the bottom of the tree trunk or tower level) and a spawn point (at the top of the tower room or tree trunk). The script goes through the array of prefabs, finds a piece, instantiates it. It then searches for the spawn point (an empty game object carefully placed in the prefab) and instantiates a new prefab on that gameobject.

The result is each piece of my tower or tree is linked from origin (set in Blender) to spawn point (added in Unity). I imagine you could take a similar approach with your rooms. You could use 2 game objects, one for entrance, one for exit. Make the position of the entrance equal to the position of the previous object’s exit and string rooms together like so.

Hope this helps. Comment if you need anymore clarification.

Thanks