How do I destroy only 1 instance

Get help using Construct 2

Post » Mon Feb 13, 2017 2:28 pm

I have a game in progress when the player fires a "Bullet" out of a gun and shoots the enemy.

Now I have multiple instances of the enemy moving around the screen and if the bullet hits the enemy the enemy is destroyed. The problem I'm having is that if say 2 or more enemy sprites are overlapping and the bullet touches 2 enemies then both enemies are destroyed.

How can I make the bullet only kill 1 of the enemies, 1 bullet 1 kill.

I obviously destroy the bullet when it hits the enemy but still if more than 1 enemy is hit by the same bullet they all get destroyed and I don't want that.
B
8
S
1
Posts: 17
Reputation: 634

Post » Mon Feb 13, 2017 2:36 pm

You could add a "for each enemy" as your last condition and add a "stop loop" action. Only one enemy would then be destroyed.
B
69
S
28
G
24
Posts: 977
Reputation: 18,739

Post » Mon Feb 13, 2017 2:37 pm

Inside de collision condition, use "Pick nth instance" (is a zero based list, so zero is the first picked object) to pick only one, then apply your "Destroy" action.
Lead developer at Octeto Studios
Visit our portfolio at: http://www.octetostudios.com/ :)
Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,614


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 62 guests