my enemies wont die when i shoot at them! need help!
i got two scripts, first the enemy health;
var health = 100;
var TakeDamage : boolean;
var texturewidth : int;
var textureheight : int;
function OnTriggerEnter(other : Collider){
if(other.tag == “Player”){
TakeDamage = true;
}
}
function OnTriggerExit(other : Collider){
if(other.tag == “Player”){
TakeDamage = false;
}
}
function Update(){
if(TakeDamage){
if(Input.GetButtonDown(“Fire1”)){
health --;
}
}
if(health < 1){
print(“Enemy Down!”);
health = 0;
Destroy (gameObject);
}
if(health == 3){
HealthFull = true;
}
}
And so the player/ shooting script;
var projectile : Rigidbody;
var speed = 20;
function Update () {
if(Input.GetButton(“Fire1”)) {
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection(Vector3(0,0,speed));
Destroy(clone.gameObject,3);
}}
Help would be greathfull!