How to implement a momentary pause

Am making a platformer game where the player can take damage from enemies
How do I make the game lag for like a few seconds when something dramatic happens like the player takes damage or he hits an enemy, kinda like what happens in most platformer games where there is a brief moment where the game lag and then continues to run normally

There are multiple ways to achieve this depending of the effect you’re after.

A basic setup woyld be to use a timer ana boolean object variable on the player (let’s say it’s called “hit”).

  • players gets hit → the timer starts / boolean “hit” = TRUE
  • timer > X sec → delete timer / boolean “hit” = FALSE

If you want the player to not be able to move or attack while getting hit, then you can add the condition (boolean “hit” = FALSE) to the movement or attack events.

If you want an effect like in megaman games, where the player freezes and moves back a bit, you can do something like this:

  • boolean “hit” = TRUE → disable platformer behavior / tween player pos back few pixels