- Home /
Animation.CrossFadeQueued: Catch 22
I have a character standing in a looping "idle" animation. When the user clicks the mouse button, the character should play a non-looping punch animation and then cross-fade back to his idle animation.
So the animation state should go like:
idle (looping) -> punch (one-shot) -> idle (looping)
Assuming that "idle" is already playing (looping), my Punch() function looks like so:
void BeginPunch()
{
playerAnimation.CrossFade( "attack" );
playerAnimation.CrossFadeQueued( "idle" );
}
Doing this does no cross-fade at all, and the player pops back into his idle animation instead of it being done smoothly. I tried setting "attack" to be WrapMode.ClampForever, but he never switches back to his idle animation and remains in the last frame of his punch animation.
So I call this a catch 22 because: 1) Cross-fading is not possible unless it is done from a looping animation 2) Queuing is not possible if you are using a looping animation (since it technically never ends)
So, having made these points, why does CrossFadeQueued even exist? According to my research, this is impossible. I would like to get my very simple cross-fading example working. Anyone have any ideas/solutions?
Answer by Robert 1 · Apr 22, 2010 at 08:12 PM
I found that by utilizing animation layers, I was able to get it working. I set attack to layer 1 and idle is at layer 0.
Answer by MaDDoX · May 16, 2010 at 02:58 PM
For the record, if you're baking keys in your source 3D application, that will only work in Unity if you also delete the keys of the non-animated joints. Or else you have the keys fighting on both layers and probably won't get the result you want.
Your answer
Follow this Question
Related Questions
How to use CrossFade with anim2 when anim1 is over? 1 Answer
isOpen queues next door to run close animation even if its closed 0 Answers
How can i play animations in a queue using the Animator? 0 Answers
Why is Animation Not Playing in Reverse? 2 Answers
Animation/CrossFade difficulties, Animation won't CrossFade 0 Answers