Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JulianDeclercq/190ccb7d608fe2dce717639cb15a117b to your computer and use it in GitHub Desktop.
Save JulianDeclercq/190ccb7d608fe2dce717639cb15a117b to your computer and use it in GitHub Desktop.
Wait (in coroutine) until current animation is finished
AnimatorStateInfo animationState = myAnimator.GetCurrentAnimatorStateInfo(0);
AnimatorClipInfo[] animatorClipInfoArray = myAnimator.GetCurrentAnimatorClipInfo(0);
if (animatorClipInfoArray.Length > 0)
{
float clipLength = animatorClipInfoArray[0].clip.length;
float timePlayed = clipLength * animationState.normalizedTime;
float timeToDelay = clipLength - timePlayed;
yield return new WaitForSeconds(timeToDelay);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment