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 /
This question was closed Apr 10, 2013 at 04:16 AM by Fattie for the following reason:

Problem is not reproducible or outdated

avatar image
0
Question by theSaruwatari · Apr 10, 2013 at 03:38 AM · javascriptarraysspawn points

Can't get objects from an array instantiate at spawn points in an array

I'm trying to spawn objects from an array to spawn points in another array. The objects chosen to be spawned must be randomly chosen, but not the spawn points. I need the code to go through each spawn point and randomly choose which object will go there. Here is what I have so far and I'm sure something is wrong in it. Oh, and all of this must happen after a button is pressed.

 var couch : GameObject[];
 var couchSpawn : Transform[];
 
 function Start () {
 for (var i=0; i < couchSpawn.length; i++)
     {
     if(Input.GetButtonDown("G") == true){
     //Select From Objects To Spawn
     var thingToSpawn : int = Random.Range( 0, couch.length );
     Instantiate( couch[thingToSpawn], couchSpawn[i].position, transform.rotation );
     }
     }
 }
Comment
Add comment · Show 1
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 Fattie · Apr 10, 2013 at 04:16 AM 0
Share

it's difficult to help with super-general program$$anonymous$$g questions like this.

if there is a VERY SPECIFIC PROBLE$$anonymous$$, please post a question explaining that

it\s very unlikely you want to do this in Start(), it's likely you mean Update()

also you would look for the ketystroke first, and only then go through the loop

consider say stackoverflow for very general progrsm$$anonymous$$g questions about loops, etc.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

11 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

Related Questions

JesseEtzler's RPG Talent System in C# 1 Answer

My array does not update when object is destroyed. How do I fix it? (java) 2 Answers

For values in array 2 Answers

make scroll chat with scroll bar 0 Answers

Send a message to multiple scripts within an Array - Javascript 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