- Home /
Question by
Reloaded23 · Sep 17, 2014 at 08:27 AM ·
animationanimatorcharacteranimationclip
Checking animation playing in ieunmerator. Is there a better way to do this?
I have a character and it has different type of animations.
I am playing particular animation at a particular time.
Now I want to check whether the animation is over or not and I want to perform some action that.
I am doing this in ienumerator. Something like this.
private IEnumerator WaitAndHoldPerformAction()
{
while(animation.IsPlaying("run"))
{
yield return null;
}
Debug.log("Perform action now");
}
Is this a good way to it or is there any other way to do it?
Comment
Answer by Paul-Sinnett · Sep 17, 2014 at 08:53 AM
You can add an event at the end of the animation. You can use it to trigger a function in an attached script.
So you could create an event "Done" and have it call your script:
void Done()
{
Debug.log("Perform action now");
}