private IEnumerator SpawnAllCarsInWave(WaveConfig waveConfig) { for (int EnemyCount = 1; EnemyCount <= waveConfig.GetNumberOfEnemies(); EnemyCount++) { //spawn the car from waveConfig //at the position specified by the waveConfig waypoints var newCar = Instantiate( waveConfig.GetCarPrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity); newCar.GetComponent <PathFollow>().SetWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns())); } }