Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by DubstepDragon · Apr 01, 2013 at 11:27 AM · proceduralsystemgeneration

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!

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image robertbu · Apr 01, 2013 at 02:06 PM 0
Share

I cannot tell what your problem is given this description. Posting your code might help. If it is 'just' accessing one game object from another, here is a link:

Accessing Other Game Objects

avatar image dorpeleg · Apr 01, 2013 at 03:25 PM 0
Share

This is a dupe question it seems... I answered the other one...

avatar image DubstepDragon · Apr 01, 2013 at 05:11 PM 0
Share

This isn't a duplicate. In the first, I asked about how I would place the GameObjects. In this, the question is how I would access GameObjects within an Array. Why did you close my question???

avatar image Ubahs · Apr 01, 2013 at 06:12 PM 0
Share

A lot depends on what you're missing from your Question. Are you able to instantiate a single room? If not, I'd recommend getting to that point before looping through and trying to setup a bunch of rooms.

If you can, you should be able to loop through your array and do what you did for that single room, but in each index of the array.

     for(int i = 0; i < AllRooms; i++)
     {
 arrayOfRooms[i] = <Whatever you do to make that single room.>;
     }

1 Reply

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Olgo · Apr 01, 2013 at 06:37 PM

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:

http://answers.unity3d.com/questions/415189/how-do-i-get-each-gameobject-to-mind-its-own-busin.html

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Procedural Generation... 2 Answers

A node in a childnode? 1 Answer

Timer help please 1 Answer

Galaxy Procedural Generation 1 Answer

Script Crashing Unity 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges