Invincibility frames not working right (Solved)

Greetings,

In my game, I have a box that damages the player if he touches it. This is to test the player’s health and “mercy state.”

This mercy state is when the player starts blinking and remains invincible for a set amount of time (In the screenshot, it’s opacity for now).

However, whenever I stand directly over of the object, things start to not work properly.

What I want to have happen
If the player stands directly on top of the damager during his mercy state, he will take damage once the mercy state expires, and the mercy state will immediately restart. He will keep taking damage and restarting the mercy state as long as he is touching the damager.

What is happening instead
When the player stands directly on top of the damager during his mercy state, he will take damage once the mercy state expires, but the mercy state will not restart. The player is also immune to any further damage afterwards. Basically, damage was taken, but the mercy state didn’t activate. Once the player moves away from the damager and touches it again, he’s vulnerable to damage again, and the mercy state starts as normal.

Can anybody please help? Your assistance is greatly appreciated ^^

1 Like

Nvm, I fixed it. I added some pausing and unpausing for the timer to make it work as intended.

1 Like