How do I make a wave system?

I’m making a wave defense game that after a certain amount of kills is reached, a new wave starts and new items are unlocked.

You can use a counter that goes up by one each time an enemy gets killed

then make it do whatever you want it to do when the target value, which will be the amount of sentries there are.

Unfortunately, because sentry spawning is limited by the amount of sentries that you place on the map while editing, this isn’t exactly ideal… if you’re okay with placing all the enemies beforehand, though, you can set up a respawn system that works based on properties: one for keeping track of the current wave number, one for overall enemy count (used to track how many enemies are to be spawned in a given wave), and one for current enemy count (so that you know when a wave has ended - the property is initially set to the value of ‘overall enemy count’ and is decremented whenever a sentry is knocked out).

You can use blocks to set the value of ‘overall enemy count’ to something like (overall enemy count + wave #) - even if the overall count is initially set to 0, it will be set to 1 because of that addition. This also makes a nice gradually increasing difficulty scale, because the values should increase quadratically (1, 3, 6, 10, 15, 21, etc)… that’s just an idea, though.

Now comes the complicated part: getting the right enemies to respawn. Arranging them in formations might be difficult, but a general solution is to have sequences of transmissions that you can send based on the wave - ‘spawn 1’ could be used to activate a single sentry, ‘spawn 2’ could be used to activate two more and send the spawn 1 message so that the first enemy is also respawned, and so forth. This method is called recursion, and it’s often used to create geometrically increasing sequences like the ‘triangular number sequence’ mentioned above.

You’ll need to decide upon a technique and set the parameter for each sentry’s Activate sentry when recieving on setting to correspond to the wave that they first appear in, but that should be simple enough. Hopefully it isn’t too difficult to get this working (and hopefully more options for sentries will eventually be added), but that should be all you need to get started.

1 Like

just to clarify, this uses a team where players are fighters and a team where players are the monster

my tiny brain did not understand what you just said

Uh… okay, so to summarize: there isn’t currently a feature for that available, but there are ways to make something similar work. One way to do that is to have each successive wave spawn all of the enemies of the previous wave plus all the enemies of the precious wave - that way, each wave gets progressively more difficult. As an example (with wires to show how transmissions travel between devices):

When the button on the bottom is pressed (or a message is sent that triggers the same result), it starts the first wave. Only one enemy responds to that message, so only that enemy spawns.
image

A transmission is sent to all devices capable of receiving it, so one transmission (i.e. wave 1) can be used to do multiple things. In this case, all transmissions above wave 1 also send ‘recursive’ messages - that is, they automatically send all the messages below them too. Wave 4 triggers wave 3, which triggers wave 2, which triggers wave 1… which doesn’t trigger any more messages, because it’s not greater than 1 (this makes it the ‘base case’). Again, wires are used to show how each higher transmission sends messages to all of the lower-level devices as well as the device on the original level.

Anyway, even if you can spawn enemies that way, they can’t move, so this ultimately ends up being a way to increase enemy difficulty over time instead of a way to make advanced spawning mechanics. Hopefully sentries will be updated and become able to do more useful things (like move), but in the meantime there isn’t much else to be done. Hope this helps!

6 Likes