How do I make the player invincible in during a knock back

0 favourites
  • 2 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi all. Simple question. I think. How do I make the player *temporarily* invincible in during a knock back? I found this discussed in other posts but I can't seem to get it working right. I thought disabling collisions of the enemy for a moment during the knockback would work out but I was wrong. The player gets knocked back in a direction depending on where he's facing and the player sprite flashes. How can I make it so that the player is invincible for a moment, isn't knocked back constantly and can walk through the enemy for a moment. Here's the code.

    Oh, one more thing before the code. On another slightly related note, what would be the smartest way of creating a health system. By that I mean, should I code player damage numbers and effects (knock back, getting frozen, etc) in the player character sheet or in the enemy character sheet?

    edit: added a capx and spelling

    Please not how the left worm is not acting as intended. All crawling worms have 3 movement behaviors: it moves and switches direction when near a wall, it moves and switches direction as its about to fall off a platform and it moves and switches direction manually if I set it using collision boxes. The left worm is changing to move right at certain spot and I have no idea why. Any ideas why this is? Looks like the other worms work correctly. Thanks everyone!

    https://www.dropbox.com/s/avdj3nm24hz9k ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you thought of using a boolean variable and a timer?

    You can create an instance variable for the player of boolean type (something like "isInvincible") and local static variable "timer" (the static part is important! It won't work otherwise).

    To the initial collision detection add the condition "X isInvicible" (so the player will only be hurt when "isInvincible" is false). And now, when the player is hit, set "isInvincible" to true and set "timer" to 1 second.

    Add another event with the condition "isInvincible". This block should countdown the timer, so add the action "Subtract dt from timer" (dt is the value you need to subtract). Add a subevent with the condition "timer < 0", and there make "isInvincible" false again.

    If the effects, knockback, freezing and stuff affect the player, program them in the player sheet. If they affect the enemy, program them in the enemy sheet.

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