// Runs each frame void Update() { //Spawn a new NPC wave using Coroutines if (npcCounter < spawnPerWave && timeToSpawn) { npcCounter++; activeUnits++; StartCoroutine (WaitForMe (spawnTime)); GameObject newSpawn = Instantiate (npcPrefab, mapPoints [0].location, mapPoints [0].transform.rotation) as GameObject; timeToSpawn = false; newSpawn.transform.parent = transform; npcList.Add (newSpawn); newNPC = newSpawn.GetComponent <NPCController> (); newNPC.MakeNewNPC (npcCounter, mapPoints); } }