How do I make a character invincible after being damaged?

  • Hi, this has been bugging me for the last hour or so and I cannot find an answer to it. How do I make a character invincible after being damaged? I have a kind of knock back effect but it still leaves the player in harms way.

    Thanks in advance.

  • Set Global Variable: Invincible = 0

    After collision with enemy, set Invincible = 1

    Wait 3 seconds (or how many second you wish for your player to be invincible)

    Set Invincible = 0

    If invincible = 1 then do not make dmg to player (you need to get this into the part of the code where player takes dmg)

    --or--

    If you have the part where: player collides with enemy event, add another event: Invincible =0

    So it would be: if player collides with enemy and invincible =0 -----> player takes damage

    Or you could use true/false instead of 1/0.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Does this help?

  • I think so, just about to try it out. Still very new to the construct 2 so fingers crossed I do it correctly.

    JUBBLY!

    It worked a treat, thanks very much guys.

  • Does this help?

    Your image doesn't show up, post it again

  • CalBro This post is 4 years old. And that advice was wrong anyway, don't use "Wait 3 seconds", use Timer behavior.

    Player On collision with enemy
    Invincible = 0
    	Player subtract 1 from health
    	set Invincible = 1
    	Player Start Timer "invincibility_remove" for 3 seconds
    
    On Timer "invincibility_remove" 
    	Set Invincible = 0
    

    .

    Another common method is to use Flash behavior. When player is hurt, start flashing, this will indicate that the player is temporary invincible. Use inverted "Is flashing" condition to check if the player can be hurt (is not invincible).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)