private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig) { for (int enemyCount = 0; enemyCount < waveConfig.GetNumberOfEnemies(); enemyCount++) { //spawns in the enemies var newEnemy = Instantiate( waveConfig.GetEnemyPfrefab(), waveConfig.GetWaypoints()[0].transform.position, Quaternion.identity); newEnemy.GetComponent <EnemyPathing>().setWaveConfig(waveConfig); yield return(new WaitForSeconds(waveConfig.GetTimeBetweenSpawns())); } }