How do I destroy only one family member instance?

Get help using Construct 2

Post » Sat Jul 09, 2016 2:07 pm

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?
Last edited by GSquadron on Sat Jul 09, 2016 2:15 pm, edited 1 time in total.
B
25
S
7
G
1
Posts: 200
Reputation: 2,530

Post » Sat Jul 09, 2016 2:15 pm

Hi, are you using a global variable or an instance variable to track your enemy health?
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Sat Jul 09, 2016 2:30 pm

TMAJA wrote: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.
B
25
S
7
G
1
Posts: 200
Reputation: 2,530

Post » Sat Jul 09, 2016 2:41 pm

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?
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Sat Jul 09, 2016 2:45 pm

Is it possible that when you attack one enemy you are altering the health on both of them?
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Sat Jul 09, 2016 2:50 pm

How to alter the health on only one of them?
And here are the events I am using:
Image
B
25
S
7
G
1
Posts: 200
Reputation: 2,530

Post » Sat Jul 09, 2016 2:56 pm

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?
B
13
S
6
Posts: 130
Reputation: 1,553

Post » Sat Jul 09, 2016 3:02 pm

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! :)
B
13
S
6
Posts: 130
Reputation: 1,553


Return to How do I....?

Who is online

Users browsing this forum: David181, OBLIVION and 65 guests