How do I destroy only one family member instance?

0 favourites
  • 8 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • I have set up the logic of my game so that when the enemy which is part of the enemies family has <= 0 health they get destroyed.

    But when I destroy it, it destroys all instances of the enemies which are part of the family.

    So if I have two enemies and I attack only one of them, both get destroyed if their health goes 0 or below 0.

    How can I fix this?

  • Hi, are you using a global variable or an instance variable to track your enemy health?

  • Hi, are you using a global variable or an instance variable to track your enemy health?

    I am using an instance variable created from the family.

  • Hmmm ok, I'm doing exactly that and my hostiles behave as expected.

    Does your code look like this?

    Enemy family - Health (less than or equal to) 0 | Enemy family - Destroy

    Do you have any extra conditions/actions in there?

  • Is it possible that when you attack one enemy you are altering the health on both of them?

  • How to alter the health on only one of them?

    And here are the events I am using:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok so I think the problem is you are deducting the damage from all the enemies - just to confirm if you fire up the game with the debug layout enabled and you shoot one of the enemies, then check the health values does it deduct it from both/all?

  • Ok so if it is that problem, the issue is the way you have set up the On left button clicked conditions. You don't reference an individual enemy/member of the family so the damage is distributed across all of them. I cant really tell what you are doing with your red squares but you need to find a way of tying an instance of the enemy family to the damage - if you could explain how your conditions work a bit more I'm pretty sure we can figure out a solution.

    Feel free to PM me if you don't want to explain on here!

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