- Home /
how to kill an enemy
when i shoot my enemy i want it to dissapear. ive already tried using the characterdamage script which the fps tutorial says to use but it dosent work, so can anyone tell me if there's any other way of doing this?
Answer by oliver-jones · Dec 04, 2010 at 06:35 PM
Well this depends on a lot of factors in your game. Such as what are you using to kill the enemy? If you are using a gun, then you need to send negative hitpoints from you gun, to your enemy. And in your enemy you want something like this:
if (hitpoints <= 0){
Destroy(gameObject);
}
The FPS destroy emeny should work, but you havnt given me a lot of info to work from. Its your gun that sends the enemy negative hitpoints.
how do i change the amount hitpoints my gun will take off my enemy?
Well, like I said, I cannot really help you unless you post your scripts that you are using.
the only script im using is the character damage script which is:
var hitPoints = 100.0; var deadReplacement : Transform; var dieSound : AudioClip;
function ApplyDamage (damage : float) { // We already have less than 0 hitpoints, maybe we got killed already? if (hitPoints <= 0){ Destroy(gameObject); } hitPoints -= damage; if (hitPoints <= 0.0) { Detonate(); } }
function Detonate () { // Destroy ourselves Destroy(gameObject);
// Play a dying audio clip
if (dieSound)
AudioSource.PlayClipAtPoint(dieSound, transform.position);
// Replace ourselves with the dead body
if (
@insanamon Please don't necropost an abandoned question asking for clarification about the original question. Common sense should dictate that it was abandoned for a reason.
Your answer
Follow this Question
Related Questions
Trap Door Question 1 Answer
Damaging enemies... 1 Answer
Enemy Health Help 1 Answer
How to make enemy tp to you after 45 sec.? 1 Answer
Destroying Enemy Help 5 Answers