Wave Delays

Hey Everyone

I was hoping I might be able to get some help improving the game a little bit.

The code in the game has all the waves spawning right in the beginning which makes the game repetitive and doesn’t help improve the difficulty over a certain period of time.

The idea I have in mind is having each wave enter the scene and start looping after the player hits a certain score. I struggle with coding in general and my scripts are basically the same as Rick’s however this task at hand seems a bit over my head but I was hoping maybe someone had a similar idea or might be able to help me with creating a script or modifying the current code to trigger the waves to enter once the player hits a certain score.

Thanks in advance.

I can only answer that question in general, cause I haven’t reached that lecture yet.

But basically you need a function to spawn the wave(s).
Then you need to check whether the player has reached a certain score playerscore >= wavethreshold and then invoke the function to spawn the wave.

1 Like

I appreciate the help. I’ll give it a go and see what happens :slight_smile:

I even found my repo from 2017 where I didn’t have this course and tried some simply things.

I implemented some wavespawning.
Have a look at this if you like.

Appreciate it

1 Like

I’m trying to implement something similar. I got it working by creating another List in the EnemySpawner script that will take the delay between waves:

    [SerializeField] List<WaveConfig> waveConfigs;
    [SerializeField] List<float> waveDelay;

...

    private IEnumerator SpawnAllWaves()
    {
        for (int waveIndex = startingWave; waveIndex < waveConfigs.Count; waveIndex++)
        {
            var currentDelay = waveDelay[waveIndex];
            var currentWave = waveConfigs[waveIndex];

            yield return new WaitForSeconds(currentDelay);
            yield return StartCoroutine(SpawnAllEnemiesInWave(currentWave));
        }
    }

This is how it looks in the Inspector:

image

It’s working fine, as long as the number of entries on both lists is the same.

1 Like

Thank you so much for the help. I think this should work perfectly. Appreciate it :grin:

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

Privacy & Terms