When I follow the tutorial, the animation does not play as expected. I have set Idle as auto-loop, and smile as non-auto-loop, but the CrossFadeQueued doesn't seem to be working as expected -> Smile never plays. I am using Unity 2021.3.1f1. I can send the project over to you if you want/ provide me with the contact details.
I.e. for the section of code:
if(!potrait.IsPlaying("Smile"))
{
Debug.Log("Playing Animation");
potrait.CrossFade("Smile", 0.2f);
potrait.CrossFadeQueued("Idle");
}
It does not seem that the idle animation is waiting for the smile animation to complete before playing. I.e. CrossFadeQueued doesn't seem to be working as expected. I.e. "Idle" overwrites the "Smile" animation, so that only "Idle" plays.
When I remove the Idle line, the smile plays as expected, however, ("Smile") starts looping after it plays even though I did not set it up as Looping.
if(hitResult.collider == colliderHead)
{
if(!potrait.IsPlaying("Smile"))
{
Debug.Log("Playing Animation");
potrait.CrossFade("Smile", 0.2f);
// potrait.CrossFadeQueued("Idle");
}
}
Hey thank you for the clarification, that has fixed my problems. I thought the Root Unit controlled the loop functionality, but it was the animation. The animation plays as expected now after that fix.
The tool is great btw, and the tutorials are really helpful. Thanks a lot for your work!
Hi!
For the "CrossFadeQueued" function to work properly, the currently playing animation must not be of the "Loop" type.
If a "Loop" animation is currently playing, it will be repeated endlessly, so it will work as "CrossFade" instead of "CrossFadeQueued".
If you played the "Smile" animation using the "CrossFade" function and played the "Idle" animation by calling "CrossFadeQueued" at the same time, but the "Smile" animation did not play, it was probably because the "Smile" animation was a "Loop" animation. In order to use "CrossFadeQueued", the "Loop" property of the "Smile" animation must be turned OFF.
You said you set Loop in the Root Unit screen, but to set the "Loop" property of the animation, you can do it in the "Animation Clip" menu, not the Root Unit.
(The function in the Root Unit screen is "Auto-Play", which specifies a single animation that starts automatically.)
(1) Select the "Smile" animation.
(2) Turn off "Loop" on the right screen.
Bake and run the game.
Now the script should work properly, and the "Smile" and "Idle" animations should play sequentially.
If the problem persists, please contact us again!
Thank you.