- Home /
How do I play death animation in the animator controller properly
I am having a problem playing my die animation on my animator controller . I have the animation set as a trigger . I even coded a line code as trigger and I still couldn't get the animation to play. Now I have it set as a tag. I still cant get it to work . I also have a pic.
I got one error NullReferenceException: Object reference not set to an instance of an object Opsive.ThirdPersonController.Health.DieLocal (Vector3 position, Vector3 force) (at Assets/Third Person Controller/Scripts/Health.cs:357) This all I got in the start function. void Start () { anim = GetComponent (); }
if (m_DeactivateOnDeath) { Scheduler.Schedule(m_DeactivateOnDeathDelay, Deactivate); anim = GameObject.FindGameObjectWithTag("Death").GetComponent(); GetComponent().Play(); } }
Answer by importguru88 · Jul 17, 2016 at 10:46 PM
I had change the parameter and code : I got this error : Controller 'bear': Transition '' in state 'AnyState' uses parameter 'Death' which does not exist in controller. Here is what I got now. UnityEditor.DockArea:OnGUI()
if (m_DeactivateOnDeath) {
Scheduler.Schedule(m_DeactivateOnDeathDelay, Deactivate);
GetComponent<AudioSource>().Play();
anim.SetTrigger("Dead");
}
}