I’m trying to code a scenario where after a zombie is killed, it runs an animation (name of the animation is “back_fall”), then waits for a couple seconds, then it is destroyed. Here is my current code:
var EnemyHealth : int = 100;
var Zombie : GameObject;
function DeductPoints (DamageAmount : int) {
EnemyHealth -= DamageAmount;
}
if( EnemyHealth <= 0 ){
GameObject.Find(“Zombie”).animation.Play(“back_fall”);
Destroytimer ();
}
function Destroytimer (){
yield WaitForSeconds (animation[“back_fall”].length);
Destroy(gameObject);
}
NOT PART OF CODE: for some reason not all of my code went into the little boxes (sorry). The console says “Type ‘UnityEngine.Component’ does not support slicing.”.