I am trying to make a spawn system for a zombie game I am making. Since I plan to have the zombies spawn only in close locations I have found all objects with spawn tag and put them in a list. Then I check to see if the spawn is in range. I then want to put that into an array for processing in another script.
Blockquote public GameControl control;
public float spawnDist = 10;
List GameObject> zSpawn = new List GameObject> ();
.
void Update (){
foreach (var obj in Zspawn){
if(Vector3.Distance(transform.position, obj.transform.position) < spawnDist)
control.spawn = zSpawn;
}
}
}
The control.spawn is my Game Control Array that I plan to use for spawning and my only problem is converting the list of zSpawn into an Array of Game Objects.
,I’m trying to get all of some gameobjects, and the way I found them was by using list. However, when I want to use the objects they are in a list and I don’t know how to convert a list into an array(GameObject).