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 );
}
}
}
↧