I’m trying to work out an animation controller. The controller stores animations in an array and when one animation finishes it calls the next one in the array.
//on animation end:
animation.CrossFade(GetNextAnimation(), fadeLength);
For the most part this is working great. However, there are some occasions where the same animation needs to be played twice in a row. If the animation returned by GetNextAnimation() is the same as the animation currently being played, no crossfade occurs. Instead, the current animation just keeps playing until it ends and then the character stops animating until I call another animation.
Is there an easy way to fade the end of an animation into the start of the same animation?
Any animation you need to play twice you should set to loop. If they aren’t looping animations you should probably go ahead an make them loop-able.
The problem is that the crossfade may not always happen at the end of the animation. For example, a jump animation. Normally this animation shouldn’t loop. However if the player gains a double-jump ability, you would want to be able to crossfade the jump animation a second time at any point within the initial jump.
This is what CrossFadeQueued is for.
However, there are some problems with CFQ, including the bug where it doesn’t respect the speed setting on the animationclip.
Thanks, this does exactly what I’m looking for. I am not modifying the speed of any clips, so that bug should not be an issue.
I saw CrossFadeQueued in the scripting documents but dismissed it before reading it fully because I was creating my own animation queue, not queuing them up through the animation component. Had I read it all the way I would have seen:
Nice, it sounds like it’ll do the trick then. I missed it the first time through as well, but someone on the forums pointed it out to me, so I might as well return the favor. 