P
PizzaGuy676
Guest
I'm creating a platform shooter in the trial version of GameMaker Studio 2 based off of HeartBeast's Platform Shooter series. I would like to create my own custom enemy spawning system, but I've run into a problem. Basically, I have a spawner object in my room that I've set two alarm events for. The first alarm is called every ten seconds to trigger a second alarm that spawns an enemy each second.
Alarm 0 (o_spawner):
Alarm 1 (o_spawner)
The second alarm is supposed to spawn three enemies and then stop. But for some reason, the enemies never stop spawning. I've tried setting alarm[1] to -1 in alarm[0], but that didn't work. I also tried using the exit function instead of setting alarm[1] to -1, but that didn't work either. I've been having this problem for several days, so I really want to figure out how to solve it.
Alarm 0 (o_spawner):
Code:
/// @description Start the wave
if instance_exists(o_player) && enemy_count_ = 0 {
wave_ += 1;
alarm[1] = spawn_rate_; //spawn_rate is equal to 1 second (1*room_speed)
}
Code:
/// @description Spawn enemies
if instance_exists(o_player) {
instance_create_layer(x, y, "Instances", o_enemy);
alarm[0] = time_between_waves_; //time_between_waves_ is equal to 10 seconds (10*room_speed)
alarm[1] = spawn_rate_;
if enemy_count_ >= max_enemies_per_wave_ {
alarm[1] = -1; //max_enemies_per_wave_ is equal to 3
}
}