Quantcast
Channel: Questions in topic: "spawn points"
Viewing all articles
Browse latest Browse all 102

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

$
0
0
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 ); } } }

Viewing all articles
Browse latest Browse all 102

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>