How to subtract health by 5 only one in 1 second

Hey guys I’ve got this code now

The situation is the ninja is in collision with enemy subtract health by 5, but I only want it every 1 second or something like that. Now if he walks on it the health goes way to fast down. Is there a solution for this?

Greetings (btw I like develop ;))

Hi, the reason why your health count is being reduced quickly is because the collision is constantly checked and counted. Try to add a ‘Trigger once’ condition in your last event.

Thanks man, is it also possible to respawn the enemy in 1 minute or something like that?

Sure, you need a timer for that: Timers [GDevelop wiki]

Thanks for the help!

I cannot add condition if player is dead, and idk how the timer works for a respawn

You could set a boolean scene variable player_dead to true if the player is dead and use that as a condition together with a timer to spawn the player after 1 min or whatever time you want. In the same event you toggle the variable back to false.

Thanks for the help this also works if the enemy is dead (in this case the elf)?

I’ve got it set tho this now. Idk how to action is called to respawn the elf

Just use the ‘create’ - action for the elf and specify the location. In the same event you have to toggle the variable back (btw you can use boolean variables true/false for that).

I’ve got this setup now, but it doesn’t respawn I can’t seem to get it fixed

You mean the ElfFemale sprite does not appear? I am just guessing but it might be because you are using an object variable (Elf_Death). When you delete the EIfFemale the variable also does not exist anymore. I would try a scene variable instead.

Thanks for previous help, I setup a timer but it doesn’t seem to work can you help me?

Instead of ‘pause timer respawn’ just add an action ’ Start (or reset) a timer ’ in the last event. This should spawn the object after 30 seconds.