How do I delay a script to wait until an animation is completed before it is enabled?
you could try something like this:
animation.Play(animation.clip.name);
// Wait for the animation to have finished
yield WaitForSeconds (animation.clip.length);
*pseudoCode*
var script: OtherScript;
script.DoThis();
//
instead of a function, just set that to enable / disable whatever you had in mind.
void CallToAnimate()
{
StartCoroutine(“AnimateAndWait”);
}
IEnumerator AnimateAndWait()
{
animation.Play(animation.clip.name);
// Now that the animation is running - wait for that long before continuing
yield return new WaitForSeconds(animation.clip.length);
// Time's up - call to what ever procedure you wish
YourFunction();
}
void YourFunction()
{
//What ever you want to do after animation is done
}
Set the animation variable to yours and function names as you please.
Make sure you use StartCoroutine(“FunctionName”), so the yield and wait are actually wroking.