I have 3 animation A,B,C.
I want to play animation A then B then C. When animation C is completed, I will show a notice.
How can I do that? I don't know how to callback when animation complete .
Thanks so much.
Use CrossFadeQueued() so the animations will play one after the other. To check if an animation has finished playing, store the AnimationState in a temporary variable:
Note: I am using C#
Add this as a member variable to your class:
Put this in Start() (change nameOfAnimation to the actual animation name):
- anim = animation["nameOfAnimation"];
Then put this in Update():
- // animation is finished. do something here
I have not tested this code so tell me if there's anything wrong.
It is not work. Because normalize time is checked before animation complete.
You can use animation.Crossfade( ) function.
Again, I said use CrossFadeQueued, not CrossFade, so that they will be played one after the other.
nomalizedTime starts at 0.0 at the beginning, 0.5 at the middle of the animation, and will become 1.0 when the animation is finished.
I want to play animation in a function , not on Start()
Example when I click a button, animaton sequence start, then show a notice when complete