How do I make enemy invulnerable for a couple of secs from bullets?

0 favourites
  • 12 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • Hey guys, im trying to get my enemy to become temporarily invulnerable to bullets. Im trying to get the bullets to go though the enemy and when the enemy is not in a temporary invulnerable state, get the enemy to become vulnerable again. How would one go about of making the bullets go through?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can add a boolean variable into your Player: isInvulnerable = false/true.

    If isInvulnerable = true, stop checking collision with the bullet.

    If it is false, do as current.

  • GamerDude96, a Boolean variable as mentioned by Maverick1912 is a good way to handle this issue but requires you to code when to disable it. I prefer to use an integer variable that stores the time to end invulnerability. When the character becomes invulnerable, you would set:

    invulnerableUntilTime = time + X seconds

    Then, when damage would be dealt to the character, you would check if:

    time > invulnerableUntilTime

    With a Boolean, you still have to set the value and check it but this completely removes the need to set the Boolean value to false. By nature of the passage of time, the invulnerability will be remove.

  • InDWrekt

    Thank you. I was looking for a simpler method of doing it without having to create a whole Boolean variable and code it then try to disable it. Your way was what I was looking for. Thanks once more.

  • InDWrekt

    Umm quick question, how would I be able to set this event wise lol?

    So I first I did

    (Event) System For each enemy3

    (SUB.E) enemy3 Invulnerable= time+10

    system every random(25)seconds >

    (Action)

    Enemy3 Opacity to 5

    wait 10 secs

    Enemy3 Opacity to 100.

  • drive.google.com/file/d/1bFw9URYwNhyfiG_TbDdZSrYoPcnlwzZX/view

    Take a look at this example. There are 2 layouts. One that has very minimal actions. All you do is click the red ball to kill it but each time it is clicked, it becomes invulnerable for 5 seconds.

    The other uses an 8 direction controlled player that will trigger the ball to be invulnerable. It also causes the ball to flash when it is invulnerable.

  • Another option is to use a timer behavior.

    You can set it for x seconds, and use the (inverted) while timer is running condition in your damage event.

  • InDWrekt

    Hmm...strange. I followed exactly how you did it and it's not working in mine. All im trying to do is get the bullets to go through the desire enemy I want, but it keeps destroying it.

  • If you can attach your project, I can take a look at it for you.

  • Thanks. You got an email? I can send it to you there because its a big project im working on and don't want to expose it.

    Just send me a email at Germane.brownzyw@yahoo.com

  • Thanks for your help man :)

  • You're welcome. Good luck with your project.

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