• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Alarm not working

O

Oniric

Guest
Hi guys, I've encountered a weird problem which I cant seem to find a solution to.

I've been using alarms in my games for quite some time now and I've rarely ever had any problems. Now I've encountered one and it really weird. So i'm currently working on a simple top/down zombie shooter and I was working with the zombie enemy. I've made a simple code so that when the zombies life reaches 0 or less the speed, direction and sprite index changes I also set an alarm so that after a couple seconds the zombie body disappears.

if zombie_alive == true
{
image_index = 0;
direction = point_direction(x,y,obj_player.x,obj_player.y);
speed = 5;
image_angle = direction;
}
else
{
image_index = 1;
image_angle = 0;
speed = 0;
alarm[0] = 60;

}

The problem is the alarm[0] is not working. If I change the value from 60 to 1 it does work. So im really confused what is going on.
Any ideas?

Thanks.
 

FrostyCat

Redemption Seeker
When setting an alarm in a continually recurring event, always check whether it has already been set before setting it. Otherwise you aren't giving it time to tick down, and alarms that have been held open like this never trigger.
Code:
if (alarm[0] < 0) {
  alarm[0] = 60;
}
 
O

Oniric

Guest
When setting an alarm in a continually recurring event, always check whether it has already been set before setting it. Otherwise you aren't giving it time to tick down, and alarms that have been held open like this never trigger.
Code:
if (alarm[0] < 0) {
  alarm[0] = 60;
}
Ooh I see now, that makes a lot of sense. Cheers dude.
 
Z

zakthdrgnslyer

Guest
When setting an alarm in a continually recurring event, always check whether it has already been set before setting it. Otherwise you aren't giving it time to tick down, and alarms that have been held open like this never trigger.
Code:
if (alarm[0] < 0) {
  alarm[0] = 60;
}
THANK YOU SO MUCH
 
When setting an alarm in a continually recurring event, always check whether it has already been set before setting it. Otherwise you aren't giving it time to tick down, and alarms that have been held open like this never trigger.
Code:
if (alarm[0] < 0) {
  alarm[0] = 60;
}
Still working in 2023 for my Key Down event, many thanks for this!
 
Top