Created
June 26, 2017 14:56
-
-
Save JulianDeclercq/190ccb7d608fe2dce717639cb15a117b to your computer and use it in GitHub Desktop.
Wait (in coroutine) until current animation is finished
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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