- Home /
How do I call an animation event on a deactivated gameobject in unity3d c#
I have a pic of the animation frames on here . The deactivation is has the animation from the health scripts is attach to the enemy ai . But the frames are different . I want the death animation to keep up when deactivation function is called . When I code it doesn't seem to work at all. I also have a sprint animation attach to the character and it just plays the animations and disappear when I kill the enemy kill close in range . It's doesn't play the death animation when I kill the character close range . What happen is the enemy ai animation sprint will still keep playing even it deactivates when the health reaches zero. So what I want it to do is play the death animation when I kill the enemy ai in close range instead of the sprint animation if that make any sense. I have some code here :
IEnumerator wait()
{
anim = GetComponent<Animation>();
anim.Play(anim.clip.name);
yield return new WaitForSeconds(anim.clip.length)
}
}
if (m_DeactivateOnDeath) {
Scheduler.Schedule(m_DeactivateOnDeathDelay, Deactivate);
GetComponent<Animation>().Play("die");
GetComponent<AudioSource>().Play();
}
}
Your answer
Follow this Question
Related Questions
Deactivate gameobject and all children 2 Answers
setActive(false) does not fire onDisable? 1 Answer
Distribute terrain in zones 3 Answers
Activating/Deactivating GameObject Problem :( 3 Answers
Multiple Cars not working 1 Answer