How do I stop double kill, single bullet

0 favourites
  • 6 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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)

  • True, ty, Ill give that a shot.

  • 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.

  • 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

  • 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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)