I have a problem with my animation Clip which is supposed to play when his health is <=0. but all it do is stop running and give me a death point which it’s supposed to do. my other animation Clips work fine.
here’s my code, it’s in C#
public AnimationClip dieClip;
public AnimationClip idleClip;
public AnimationClip runClip;
public int moveSpeed;
public int rotationSpeed;
public int maxdistance;
private bool dead;
void Update () {
if (health > 0) {
moveSpeed = 3;
rotationSpeed = 5;
animation.CrossFade (runClip.name);
Attack ();}
if (Vector3.Distance (target.position, myTransform.position) < maxdistance)
{
animation.CrossFade (idleClip.name);
}
private bool isdead(){
//bool dead = false;
if (health <= 0 && !dead) {
moveSpeed = 0;
rotationSpeed = 0;
animation.CrossFade (dieClip.name);
dead = true;
StartCoroutine ("enemyDead");
collider.enabled = false;
scoreManager.kills += 1;
scoreManager.killsCoins += 1;
}
return dead;
}
}