Make the player invincible for 1.5 seconds after being hit?

0 favourites
  • 11 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello, I would like to know how to make the player invincible for a short while after they touched an enemy. They'll be flashing for 1.5 seconds and cannot be damaged during that time. I couldn't find the answer in other posts about the subject...

    Here's my game so far: dropbox.com/s/tutthxjv3of0l ... s.c3p?dl=0

    Have a nice day/night!

  • hiya, you can use a condition so when you get hit during the 1.5 seconds, for example set a variable to 1 then back to 0 after 1.5. Then under your damage event you add the condition when variable = 0, so when variable is 1 during that 1.5 seconds you cannot be damaged.

  • You could just use another condition in your damage thingy. If player not flashing ( assume that is an animation ) damage = OK.

    So as long as it is flashing it will not pick up any damage

  • hiya, you can use a condition so when you get hit during the 1.5 seconds, for example set a variable to 1 then back to 0 after 1.5. Then under your damage event you add the condition when variable = 0, so when variable is 1 during that 1.5 seconds you cannot be damaged.

    Hello! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy" />

    I'm not sure I understand. I did the following:

    The save file: dropbox.com/s/j5mna8o404m85 ... 9.png?dl=0

    I probably did this incorrectly... The character still can take damage after being hit but it takes 1.5 seconds for the hearts to disappear and the splatter to appear.

  • You could just use another condition in your damage thingy. If player not flashing ( assume that is an animation ) damage = OK.

    So as long as it is flashing it will not pick up any damage

    Hello, the character flashing is part of a behavior. When you say "damage = OK", are you talking about a variable?

  • EMA2826

    Don't use "Wait" action for this! This is a mistake many beginners make and it can cause all kind of bugs and problems.

    Use Timer behavior instead.

    Set Invincible=1, start Timer for 1.5 seconds.

    On Timer event, set Invincible=0

  • I mean that in your event where you add damage ( I assume it is on collision with enemy/bullet ) you need to add another condition :

    In your case if using flashing behavior, just ad player is flashing condition, then invert that ( add it to your event that checks for collisions and ads damage ).

    That means even if colliding with enemies and bullets he will not take on damage while flashing

  • BadMario dop2000

    Game so far: dropbox.com/s/pv31ciycluvco ... 2.c3p?dl=0

    Hello, I did all those things separately and even together and it doesn't seem to work (probably did it incorrectly once again. Sorry!). It's so strange that such a basic game mechanic can be so hard to implement. Is it a problem related to Construct 3 itself, by any chance?

    Have a nice day!

  • You forgot to add "Player invincible=0" condition to your "Player on collision with enemy" event on the screenshot.

    When invinicble is not 0, the collision will simply be ignored.

  • Allow me to add to the conversation by pointing to my (paid) addons :

    • Health lets you toggle invincibility with a simple action.
    • As said previously, the wait action can cause all sorts of problems, the solution is using FSM to create two states: "Idle" and "Invincible", and using a timed transition to go from invincible to idle.

    I'm going to release a Construct 3 update to the addons by the end of the week. You can buy them now and receive the update for free.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You forgot to add "Player invincible=0" condition to your "Player on collision with enemy" event on the screenshot.

    When invinicble is not 0, the collision will simply be ignored.

    Thank you! It worked!!

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