Destroy only a specific instance of an object

Get help using Construct 2

Post » Mon Jan 27, 2014 6:42 pm

Hi, I wanna have only a specific instance of an enemy object destroyed when the player attacks it (obviously, only the instance that was attacked). When I attack, every instance of my enemy is destroyed. The same applies when I have the enemy touch an object that makes it jump (all instances of the enemy jump, even the ones that didn't touch the object). Thanks in advance for any help
B
5
S
1
Posts: 15
Reputation: 341

Post » Mon Jan 27, 2014 6:52 pm

you are not picking (referencing) the object in your event.
When Construct doesn't know which object is meant all objects are affected.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jan 27, 2014 7:27 pm

How do I go about picking just the instance that I attacked?
B
5
S
1
Posts: 15
Reputation: 341

Post » Mon Jan 27, 2014 7:34 pm

For that we'd have to see how you have your events set up.

could be adding a check as subevent of the attack would work,
could be using syatem for each,
could be pichk by comparison,
etcetera.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jan 27, 2014 7:54 pm

The short of it is, the player has an attack box sprite that's called when they hit a button. The event is set so that if the attack box collides with the enemy, the enemy loses a point from its health variable. Then I have a separate event where, if the health variable is less than or equal to 0, the enemy is knocked back, spawns some explosion sprites and then is destroyed.
B
5
S
1
Posts: 15
Reputation: 341

Post » Mon Jan 27, 2014 8:01 pm

You should post a capx using dropbox maybe, it can help when you need assistance.
In your case, you select all the enemies and make the die. It could come from numerous cases... and a simple instruction could correct it. Without the code though, the only general solution I see is, in the event where you remove 1 from health, add a sub event where the trigger is "enemy.health<= 0" and the action is the animation you put later.
Or if you want to keep the animation somewhere else (because multiple ways to die), you change the trigger with a Function call, and call that same function on the sub event I described before.
As you are starting with C2, all this may make no sense, so I strongly suggest, as did LittleStain, that you post a .capx showing the problem the simplest way possible...
B
17
S
8
G
4
Posts: 461
Reputation: 6,137

Post » Mon Jan 27, 2014 8:17 pm

Adding the condition

system for each enemy

to the enemy health check event would probably solve it, but I would recommend reading the manual on how events work, it will make it more clear why this is happening.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jan 27, 2014 8:19 pm

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests