Hi! Im working on a game for my studies and faced a problem, along the way. So...
What Im trying to accomplish?
A battle arena system, in which after you enter a certain zone, enemies will appear. Once youd defeat them, a second enemy wave would start. Then after that a third one etc. until all waves have been defeated
What I tried to make it work?
First of all, I made two global variables: Arena Wave Counter, which indicates the current wave number and Wave Enemy Counter, which indicates the number of the enemies of each wave. At the end of the corridor, that leads to the battlefield, theres an object, which when the player collides with, is supposed to launch the first wave. Around the zone, there are portals, of which each of them is supposed to spawn an enemy, one at a time, when the wave starts. To indicate when enemies of the current wave are defeated, for the next wave to start, I simply put a value at Wave Enemy Counter just before the wave group activates and that value is as much as I create or spawn enemies for that wave. The way, the value changes is that, whenever an enemys HP reaches zero, it subtracts one from the Wave Enemy Counter. Once it reaches zero, I set a value that represents the next wave, activate the group of that wave, set the number of the next waves enemies and deactivate the group of the wave I just finished. For details, I added these pics of my code.
What went wrong?
First of all the enemies are spawning before I touch the corridor fence, secondly for some reason, hundreads of enemies are spawning instead of the few, I told the system to be created. I dont understand at all with what logic these atrocities happened.
So Id be really grateful for help for fixing this code, or for creating the arena system, with perhaps a completely different way.