- Home /
Death and animations
Quick question guys in relation to triggering an animation after death. I am using the 3rd person controller that comes with unity for character control.Everything is set up and working fine but there is no death animation if the player is destroyed. I have one ready to go I just need to know how to call it from the script. I found the animation.play tutorial on untiy's scripting reference site but don't really get how to implement it. Any help much appreciated!
Answer by cowasockytommy · Apr 19, 2013 at 10:26 AM
animation.CrossFade("name of animation");
Hey cowasockytommy! Cheers for the reply! Just wondering where I would put this line? Does it do into my 3rd person controller script? And if so do you know where? Completely new to this, learning as I go!
well it depends. basicly you only have that script right?
but yes most likey in your 3rd person controller script is where it would go
function OnTrigerEnter(oth: Collider)
{
if(oth.gameObject.tag == "")
{
animation.Play("");
yield WaitForSeconds(2);
Destroy(gameObject);
}
}
//did you give the enemy a tag?
and here i did this in java script no errors for me
i did some changes