Spawning Multiple simultaneous waves

i just gave a quickly look at your response and i wanted to say that the “time between spawns” parameters didn’t referred to the waves spawn time but to the enemy in the single waves , so it’s more like how much each enemy in the wave is distancieted between each other

So i did this, this is still a bit “raw” but it works fantastic, and it will permit to implement a lot of things later
i did this at first :
-a different gameobject with a different game script with the waves i want to happen simultaneously, like a “parallel enemy spawner”

-while in the “serial enemy spawner” object i put a script which holds an array of boolean that in a dinamic way sees when an enemy wave has started, i wrote the initialization of it at awake so it began with all of the wave fields at false

[SerializeField] bool[] WaveBegan;
 private void Awake()
    {
        WaveBegan = new bool[waveConfigs.Count];

        for (int i = startingWave; i < waveConfigs.Count; i++) { WaveBegan[i] = false; } //
    }
  • while all of this the parallel enemy spawner script is waiting in a coroutine for the correspective enemy wave to be “began = true”
  • i put also a [serialized field] which holds for each element what i want that specific wave to be parallel with, it is like “element 0 (wave 0 on the parallel spawner) = number of the wave to be simultaneous in the serial”
 private IEnumerator SpawnAllWaves()
    {
        for (int waveIndex = PstartingWave; waveIndex < PwaveConfigs.Count; waveIndex++)
        {
        
            while (SerialSpawner.GetWaveBegan(SimultaneousWaveNumber[waveIndex]) == false)
            {
                yield return null;
            }

            var currentWave = PwaveConfigs[waveIndex];
            yield return StartCoroutine(SpawnAllEnemiesInWave(currentWave)); //finchè non ha finito spawnallenemies

            
        }
    }

Like this the wave 5 of the P_enemy spawner will be executed simultaneously with the wave 0 of the enemy spawner, if i had wrote 1 in the simultaneous wave number it would have been simultanous with the wave 1
image

image

i don’t know if i explained my self clear, but this works for me soo all good hahaha thank you all!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms