Functioning of crossfadequeued and crossfade

I have to play animations one after another.
Something like that:

Action()
{
   animation.Play("idle");
   animation.Play("run");
   animation.Play("walk");
   animation.Play("idle");
}

If i use PlayQueued it works fine but there is a “jump” between animation.
So i think that is better if I use CrossFade or CrossFadeQueued.
I try a lot of time with these functions but they dont work (obv my fault).
Sometimes first animation never stop, sometimes only the last animation starts ecc ecc.
Can you help me? :expressionless:

For now, if you will call Action() method, all animations will be played. You could use switch case statement to call specific animation using just one method.

Action(1); //will play idle
Action(3); //will play walk

Action(int state){
    switch (state){
    case 1:
      animation.Play("idle");
      break;
    case 2:
      animation.Play("run");
      break;
    case 3:
      animation.Play("walk");
      break;
    case 4:
      animation.Play("idle");
      break;
    }
}

You’re right about Play making the bones jump. Play snaps to the first animation frame, whereas CrossFade smooths from the previous animation to the new one over a few frames. It also works like Play if there was no previous animation. So there’s never any reason to use Play. CrossFade is just better.

Your problem with CrossFadeQueued is probably that it only starts after the previous animation stops. A looping or clampForever animation never stops. CFQ only works if the current animation is PlayOnce (or Default?)

If you really need to walk for a bit then sit, a coroutine might help: CrossFade("walk"); WaitForSeconds(2.0f); CrossFade("sit");. But those are hard to interrupt properly (if you jump after a second, hard to cancel the sit.) Could just use flags and timers, such as: if(action==1 && Time.time>startedAction+2.0f) { CrossFade("run"); action=2; startedAction=Time.time; }