How to blend FBX animations

Hey guys I’m using FBX to load in some animations. I’m having trouble blending them however. I’m simply trying to get my mixamo model from an idle animation, to walk, and back to idle upon key events.

But when I try to blend the animations, the model reverts back to a T-Pose before blending to the next animation. I’m not sure why this is happening. my play action method is below

        this.playAction = (action, loop) => {

            var a = this.mixer.clipAction(this.anims[action]); // get request animation clip
            var b = this.mixer.clipAction(this.anims[this.curAnim]) // get cur anim clip

            this.curAnim = action;
            this.mixer.stopAllAction();
            b.weight = 0;
            a.crossFadeFrom(b, 1);
            a.weight = 1;
            a.play()

        }

thanks

Try it like shown below. The code performs a crossfade from idle to walk.

const idleAction = mixer.clipAction( idleClip );
const walkAction = mixer.clipAction( walkClip );

idleAction.play();

// after two seconds, start crossfade

setTimeout( function() {

	walkAction.play();
	idleAction.crossFadeTo( walkAction, 1 );

}, 2000 );

Live demo: https://jsfiddle.net/zt2wsfeb/1/

1 Like

Hi, thanks for the quick reply.

This code below worked for me. I think the key for me was stopping all anims and playing both old anim, new anim + the crossfade.

        this.playAction = (action, loop) => {
        if(action !== this.curAnim){
            var a = this.mixer.clipAction(this.anims[action]); // get request animation clip
            var b = this.mixer.clipAction(this.anims[this.curAnim]) // get cur anim clip
            this.mixer.stopAllAction();
            this.curAnim = action;
            b.play();
            b.crossFadeTo(a, .25);
            a.play();
        }
    }

Yeah, playing both animations was the missing bit!

@Mugen87 Can you please explain how would animation a waits for b to finish?
I am currently having some animations and I do listen to the event listener of finished animation before starting the other, but I am not sure how to use the blending at the event listener of finished animation for the previous one…

Do we still need to use event listener for animation to finish before staring the other animation incase of using blending?

As I noticed in the code above:

b.play();
b.crossFadeTo(a, .25);
a.play();

without any waiting… ?

Thanks in advanced.