Different Weapons & Bullets Hitting one enemy.

0 favourites
  • 4 posts
From the Asset Store
Futuristic Weapons Vol 1
$7.20 USD
40% off
Futuristics Weapons Vol 1 includes 8 different weapons, in a total of 216 sounds
  • Hello Every One How things Going on?

    I am making a top down stealth and shooter game. in this I have experienced a problem and trying so much but could not solve it. the problem is when I shoot an enemy with one weapon and when the bullets runs out I switched to another weapon with different bullet but the enemy is not destroyed.I gave only one instance variable to the enemy called Health=20 and when the player shoots the enemy with the pistol the health has to reduce to 3 and when the player shoots with the machine gun the health drops by 5. so there is a clash in the number I gave in the instance.If the enemy is left over with the health number that could not match with the second weapon life taking number its not working.

    ..........................................................................PLEASE DO HELP ME FIX THIS................

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure I understand. It sounds like you are making the enemy die when health = 0, rather than testing if health <=0. If you test whether the health is at zero or lower then it works. Otherwise damage has to make the enemy go perfectly to zero health.

  • Thank You for the reply. and Its working when I changed it to <0.

  • Hey man! I know it's a long time since you posted this, but anyways...

    This is a common issue for new programmers in any platform and in Construct it wouldn't be different, so I think it's worth the advice:

    If you're managing Health on players/enemies/cars/whatever, you normally (not always but normally) don't want the health points go below zero. It almost always cause a bug somewhere, with logic or HUD. A good habit to have is to always make those process of adding or subtracting health into a function. Like, a function called "DamagePlayer" that reduces an X amount of life from the player based on the parameter you send. In this function you can make the calculation like "if player's health is below zero, set it to zero". It does takes a bit more time, but it's really simple to do. So, in your case, whenever a bullet hit a player you'd call this function with the bullet's damage value as a parameter. You could add an N amount of different bullets and it'd still be setting the life to zero properly, avoiding this kind of error that can be a pain in the *ss to fix on later states of development.

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