Hello,
What id like to do is Instantiate an array of Prefabs to an array of Spawn points.
Say i have 5 prefabs in the objectsToSpawn Array, id like to spawn those prefabs at the
array of spawnLocations.But say i have 6 spawnLocations i want to randomly select from my 5 objectsToSpawn and fill the 6 spawn points.
Whats happening is it randomly selects from the prefabs and spawns 1 object in a random spawn point from the spawnLocations Array.
Heres My Example Code:
//Objects To Spawn var objectsToSpawn : GameObject[]; //Spawn Locations var spawnLocations : Transform[]; function Spawn() { //Select From Objects To Spawn var thingToSpawn : int = Random.Range( 0, objectsToSpawn.length ); //Select From Spawn Locations var placeToSpawn : int = Random.Range( 0, spawnLocations.length ); Instantiate( objectsToSpawn[thingToSpawn], spawnLocations[placeToSpawn].position,transform.rotation); }
Sorry i cant be more clear but i hope You can understand what i am trying to do.
Thanks for the help!