How do I stop double kill, single bullet

Get help using Construct 2

Post » Thu Mar 20, 2014 12:03 am

Having an issue in an arrow defense game where my bullet collides with two enemy's who's hitboxes are overlapping on their leading side, causing both to be destroyed by a single bullet but only be counted as one.

Here's what my code looks like:

Bullet on collision with Enemy - Destroy Bullet, & Subtract Bullet.Damage from Enemy HP
>& if HP </= 0 - Destroy Enemy, & Subtract 1 from Number_of_Enemies, & add 1 to Score

Game Completes when Waves = #, & Number_of_Enemies = 0

My Testing Information is showing more Enemies are being destroyed then whats being created.

Edit: Actually now that i put it in writing and think about it i have no idea whats going on.. but like i said, i got more kills then enemies.
B
7
S
1
Posts: 43
Reputation: 513

Post » Thu Mar 20, 2014 12:30 am

Add "Pick Top/Bottom" condition, so when the arrow collides with both enemies, the event will only pick the top one (the one the player can see)
B
84
S
22
G
15
Posts: 1,039
Reputation: 15,249

Post » Thu Mar 20, 2014 12:48 am

True, ty, Ill give that a shot.
B
7
S
1
Posts: 43
Reputation: 513

Post » Thu Mar 20, 2014 12:57 am

Another way I find useful is to your bullets, add a variable called Target and as your turret fires you add the UID of the turret target to the bullets Target variable.

The reason for this is when the bullet hits the enemy you can use this to make sure that it will only hit that target. This also solves the problem that the turret is actually shooting at its target and not just towards it, as the bullet will collide with the first enemy it hits. But if you plan to make any form for "tactics" for your turrets you will have to add something like this, so the player can actually count on the turrets attacking the targets they should.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,838

Post » Thu Mar 20, 2014 1:02 am

Yeah i like that concept. Not what im looking for here, but I'd like to implement that somewhere.

Yeah so, pick top worked for the double kills but im still getting more kills then I should be able to...

Just ran the layout a few times, 4 times it worked as it should but on one occasion it spawned 29 enemies but somehow i got 30 kills
B
7
S
1
Posts: 43
Reputation: 513

Post » Thu Mar 20, 2014 2:39 am

Still not sure why I was getting more kills then Spawns, but I moved the "check if enemy has no hp" to every tick, and its now working as intended
B
7
S
1
Posts: 43
Reputation: 513


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 45 guests