Wave System

Hi,

I am making a game which has waves of AI spawning and walking towards their target point.

I have made my AI as a blueprint actor and have made my wave system inside the level blueprint.

what I would like to know is how could I make my wave system count the AI that is spawned in the level and only start the next wave when the first wave of AI are killed instead of setting a delay since the last AI is spawned and so on.

I’m sorry in advance because im still a beginner with blueprints and hopefully someone could explain it to me as simple as possible and probably be ready to receive more questions from me. If more details are needed please do let me know and i will try my best to provide it for you :slight_smile:

This is my wave system blueprint that is setup inside the level blueprint.

just to organize things, in my case i created a “Spawner” blueprint, i created an event to spawn enemies in this BP, then i put a lot of spawners in the world, and store a reference to the blueprint that is going to spawn them, in my game, i’m not using a wave system, so i put the reference to the spawners in trigger box around the world, so when i hit the trigger box i spawn enemies (that’s not helping counting the enemies yet, but i will get there)

this is what the details panel show in the world, here i can control how many enemies of each class will spawn:

126147-details+panel.png

and this is how i call the event. the rate multiplies the value of each enemy from the details panel, so you can set it to 2 if the player choosed to play in “hard” for example and easily double the number of enemies.

126148-spawning.png

and at last, i would recommend you spawning the enemies from the “GameMode” instead of spawning from the level BP, the reason is: if you want to create a new map you could use the same game mode and everything would still work, and it’s easier to get a reference to the game mode.

TO THE POINT:
after spawning the zombies you could create a loop with break: with “get all actors from class” in case you have created a parent class to all enemies that stores the HP, then get their HP, if the HP >0 break and delay 1 second, then go back to the “get all actors from class node”, if you get to the end of the vector it’s because all enemies are dead (got HP<=0), and you can spawn a new wave.

in case you don’t have a parent class like i said, you can also do something different, you would need to destroy all the enemies when they die, and add a tag to all of your enemies, then use the same loop system with “get all actors with tag” so if the array is empty, it’s because all the enemies were destroyed and you can spawn a new wave, if there’s something in the array, it’s because there are still enemies alive, then go back to the “get all actors” node.

another option, put the spawning code in the gamemode, and create a variable and an event called “enemy down”(or something like this, i’m not good with names), every time an enemy is spawned you increase the variable, then, in the enemies code, you have to do a check every time your enemies take damage, if they died you get a reference to the game mode(you can get the reference with “get game mode”, you will have to cast to your game mode class after ir), and then call the “enemy killed” event, the “enemy killed” event should decrese the variable you created by 1, and if it’s=0 it call’s the new wave.

Hi,

I am trying to setup the method with “get all actors with tag”

I have setup that when the enemy is killed then they get destroyed and I have also added a tag to them. Sorry I haven’t really used arrays or loops before, would you be able to show me a setup that would fit into my level blueprint and where would this be inputed, after the first wave Ai are spawned or before the wave? sorry if I sound stupid like I said im still getting my head around blueprints :slight_smile:

your efforts are very appreciated :slight_smile:

Thanks!

in your code there’s a delay(of 30 seconds) before each wave, delete this delay node and put the following code in the same place (between “simple move to location” and “sequence”)

WOW!! thank you so much for the clear explanation!! it works perfect and exactly what i wanted to achieve!! really appreciate your effort :slight_smile: Thanks again!!!