IEnumerator SpawnAllMeteorsInWave(WaveConfig currentWave) { for (int i = 0; i < currentWave.GetNumberOfMeteor(); i++) { int random = Random.Range(0, currentWave.GetMeteorPrefabs().Count); var meteorClone = Instantiate(currentWave.GetMeteorPrefabs()[random], currentWave.GetWaypoints()[0].transform.position, currentWave.GetMeteorPrefabs()[random].transform.rotation); meteorClone.GetComponent <MeteorPathing>().SetWaveConfig(currentWave); yield return(new WaitForSeconds(currentWave.GetTimeOfSpawn())); } }