My apologies, got it now! Won’t make that mistake again! I’ll try the parse in and see if that works better for you.
I still can’t get it to work, it’s closer to being right, the timing is right and it’s spawning both waves now but it still won’t spawn wave 1 (green) in the right place, it starts that in the centre.
This is the change to the code, not sure if I’m still slightly off in the code formatting or there’s something in the inspector or heirarchy I need to set but I’ve toggled everything. Worst comes to worst, i should be able to carry on with the lectures as I don’t think it’ll cause issues as such right, just won’t look right visually?
using System.Collections.Generic;
using UnityEngine;
public class EnemySpawner : MonoBehaviour
{
[SerializeField] List<WaveConfigSO> waveConfigs;
[SerializeField] float timeBetweenWaves = 0f;
[SerializeField] WaveConfigSO currentWave;
void Start()
{
StartCoroutine (SpawnEnemyWaves());
}
public WaveConfigSO GetCurrentWave()
{
return currentWave;
}
IEnumerator SpawnEnemyWaves()
{
for(int i = 0; i < currentWave.GetEnemyCount(); i++)
foreach (WaveConfigSO wave in waveConfigs)
{
Instantiate(currentWave.GetEnemyPrefab(i), currentWave.GetStartingWaypoint().position, Quaternion.identity,transform);
yield return new WaitForSeconds(currentWave.GetRandomSpawnTime());
currentWave = wave;
}
for(int i = 0; i < currentWave.GetEnemyCount(); i++)
{
Instantiate(currentWave.GetEnemyPrefab(i), currentWave.GetStartingWaypoint().position, Quaternion.identity,transform);
yield return new WaitForSeconds(currentWave.GetRandomSpawnTime());
}
yield return new WaitForSeconds (timeBetweenWaves);
}
}
type or paste code here