Bullet Spread Won't Kill Enemy

0 favourites
  • 9 posts
From the Asset Store
Check preview, download and add value to your games.
  • With my new implementation of spreading bullets, now when you hit an enemy up close (3 bullets contact enemy) the enemy won't die.

    This makes no sense.

    File

  • it worked for me, the problem is that the spread is so wide that it takes the enemy being right up to the gun for all 3 to hit and kill in 2 shots. but its working the way it should on my comp at least.

    Edit: maybe a strait 3 round burst per click would work?

  • Works here as well.

  • The way it should work is the health is 5 for each enemy, so if two close range bullet hits with spread would take away 6, which kills the enemy. But this is not happening.

  • Currently its setup so that each bullet takes away 1 from the variable. So u have 3 bullets spreading if only one bullet hits the monster (because the monster is too far away ) then it only takes away 1 health. If the monster is close then all 3 bullets hit the monster and take away 1 each for a total of 3. U need to switch the amount the bullet takes off to 3 if you want it to work the way you say.

    Bullet>On collision with monster> Monster spawn explosion

                                      Bullet Destroy

                                      Monster subtract 1 from health

    That is the current setup.

  • I've made a video to show my problem, I think it's a bug with Construct 2. Notice the enemy takes several bullet hits (>10) before it dies. Link

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The bug is in the code.

    Event13 Instead of monster.health=0 try monster.health<=0 (since if your monster takes 6 shots, its health value is -1, not 0)

    Please change the title of your video on youtube.

    Your capx with text objects on the monsters to see their health

    The fixed version (in event13)

    This was to see how each monster behaved.

  • Awesome! Thanks.

  • When you are dealing with enemy health, you should always set up the death event so that it's like

    When EnemyHealth LESS THAN OR EQUAL TO 0

    Because the way things work, often you can "overkill" an enemy and nothing will happen to it at -1, -3, or -500 health.

    Basically, a lesson you should learn is that when you code in C2 (or anything else) you have to think of ALL the possibilities in your game. In this case, you can't just think "What happens when enemy's health is 0? Easy, death." You have to think "Well what if he's shot a whole bunch of times really fast? What if his health is below 0?"

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