Question about Bullets and Collision

Get help using Construct 2

Post » Wed Mar 06, 2013 3:00 am

I seem to be having this problem when two objects are overlapping each other and a "bullet" hits the objects at the same spot. They are both getting hit (when the bullet should only be hitting one of the two). Is there a way to make one object only pick one other object upon collision?

Basically the way the algorithm is set up, both mobs die at the same time, but only one is registering with my tracking algorithms. If I was expecting two mobs to die, but only one registers upon death, the player is only rewarded for one death. Sure I can track the number of destroys that happen, but the section of code that tracks the instance variable for health only seems to track it for one of the two mobs. The code looks like this:

Family: Current HP <= 0 ---> addCash then Destroy

B
3
Posts: 2
Reputation: 579

Post » Wed Mar 06, 2013 3:05 am

You could give the bullet a CanKill instance boolean, than dd the condition that it must be True to kill an enemy, when it hits an enemy immediately set it to False.
B
40
S
12
G
7
Posts: 603
Reputation: 7,656

Post » Wed Mar 06, 2013 3:22 am

System: Bullet -> On Collision with Object
System: Pick Object Instance 0 (pick nth instance)

This will always pick the first instance in a collision event regardless of how many instances are returned.
B
26
S
8
G
3
Posts: 210
Reputation: 5,973

Post » Wed Mar 06, 2013 5:04 am

I tried out theubie's suggestion and it seems to be working properly. EncryptedCow, I didn't get a chance to try out your suggestion =\... Thanks everyone!
B
3
Posts: 2
Reputation: 579


Return to How do I....?

Who is online

Users browsing this forum: djcrazypants, marekmk and 6 guests