I need to add a death animation for my zombie. The only problem is the only script that works for me destroys the zombie before it can play an animation and sit on the ground for five seconds. Can anybody add an animation to the script? Thankyou.
Here is the script…
#pragma strict
var health = 10;
var TakeDamage : boolean;
var myCollider : Collider;
function OnTriggerEnter(other : Collider){
if(other.tag == "Player"){
TakeDamage = true;
}
myCollider = other;
}
function OnTriggerExit(other : Collider){
if(other.tag == "Player"){
TakeDamage = false;
}
}
function Update(){
if(TakeDamage){
if(Input.GetButtonDown("Fire1")){
health --;
}
}
if(health<= 0){
print("Enemy Down");
health = 0;
if(myCollider != null)
{
Destroy(myCollider.gameObject);
}
}
}