[SOLVED]Need help with timer after player death

J

jaigantor

Guest
hey so this might be a bit big (pulling code from a few objects) but I'm having an issue where the timer I have set to start after the player death doesn't work here's the code:

in the object o_timer
create:
global.timer = 3;
if instance_exists(o_player){
alarm[0] = 0;
}else{
alarm[0] = 60;
}

in alarm 0:
global.timer --;

when an enemy collides with a player the play is destroyed and in the o_player destroy event is this code:
if global.timer == 0{
room_goto(Death);
}

i'm not sure why this won't work, any help appreciated.
 
There are lots of ways to do this but here's one, based on what you seem to have in place:

In the destroy event of the player, put:
Code:
o_timer.alarm[0] = 3 * room_speed; // start a 3 second alarm inside the o_timer object
In the alarm 0 event of the o_timer object put:
Code:
 room_goto(death); // go to the death room when this alarm triggers, which will be 3 seconds after player death
(You can get rid of all the global.timer code)
 
J

jaigantor

Guest
There are lots of ways to do this but here's one, based on what you seem to have in place:

In the destroy event of the player, put:
Code:
o_timer.alarm[0] = 3 * room_speed; // start a 3 second alarm inside the o_timer object
In the alarm 0 event of the o_timer object put:
Code:
 room_goto(death); // go to the death room when this alarm triggers, which will be 3 seconds after player death
(You can get rid of all the global.timer code)
Thank you so much, this works perfectly!
 
Top