• 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!

How to fix a death dealy

  • Thread starter pierrelouis.gaucher@gmail
  • Start date
P

pierrelouis.gaucher@gmail

Guest
Hello everyone,

I'm trying to create a delay when my player dies because I don't like the instant return to the room when he dies, I tried with alarms and it doesn't work. Maybe it's a problem with my oPlayer step, I don't know :/ I'm working on it from 3 hours and it's still not working.
I created a short animation of death, i want this : when my player enter in collision with an ennemy, my player can't move and the animation of death is launched for something like 1 second, then it goes to the beginning of the room (in fact it's a little bit more complexe I want that when my player dies, he goes to the previous room, and if he dies again he goes to the previous previous room etc )
I can give you any piece of code you want for fixing it

Thanks :)
 

Niels

Member
Make a variable in the create event:
Death = false;

(Depending on how the player dies, for example when colliding with enemy)
Collision event:
death = true;
Sprite_index = (your death sprite animation);
Image_index = 0;

Step event:
If death = true {
If image_index> image_number -1{
room_restart()
}
}
 
P

pierrelouis.gaucher@gmail

Guest
Ok thanks it looks good but there's still no delay before room_restart and I really want to do that
 

saffeine

Member
what's the code that you have for the death timer ( the one that starts the countdown, and the code that triggers it )?
 

Yal

šŸ§ *penguin noises*
GMC Elder
This kind of thing usually is easier with a separate "player death" object. When the player dies, destroy them and create a "obj_playerDie" at that position instead. The death object handles the animation, and restarts the room in its Animation End event (found under the Other category).

Splitting stuff off like this has some benefits, like not having to worry about the player chain-dying when hit by an attack in its dead state (which could happen with a "death is just a state in the normal player state machine" solution) so I recommend it for states that should cut off all standard interactions.
 
Top