yield WaitForSeconds for animation's time

Hello there,

I need to know if i can use yield WaitForSeconds to calculate my animation’s lenght, like it can be done with audio.clip, for example :

yield WaitForSeconds (audio.clip.length); 

This calculates the lenght of some audio clip, i wanna know if i can get this same result for my animation’s clip lenght; I’ve tried this :

yield WaitForSeconds (MYANIMATIONCLIP.length);

it doesnt work ):

This is even possible to do it?

Thanks in advance

Give this a try:

var yourAnim: AnimationClip;

function Start () {
	yield WaitForSeconds(yourAnim.length);
	Destroy(gameObject);
}

Or, if you just want to refer to the animation that’s in your Animation component in the inspector

yield WaitForSeconds(animation.clip.length);