Addmixing face character animation - additive animation has no effect?

Hi.

I'm making character animation in several layers, but I can't make work `AnimationBlendMode.Additive`. Using `AnimationBlendMode.Blend`, animations gets played (but obviously I can't add them).

I think I managed to make it work in earlier tests, but now I'm really stuck with this. I think it could be related to the mesh export-import process (Blender) or so.

I'll include the code and the complete test project.

I'll appreciate any help

// This code illustrates my inability to get Add two animations.
// The intention is to have a face abled to gesture with the
// various parts (mouth, eyes, nose, etc..) independently.

// I try to reach this with several layers (two in this test)
// one on each part of the face, so that the animations of each
// part can be mixed without interfering with others.

// Just push '2' after start
// The idea is to push '1' to return to netural expression
// (but it doesn't work)

var status = "" ;

function Start () {
    animation.wrapMode = WrapMode.ClampForever ;
}

function Update () {    
    if (Input.anyKeyDown) { tecla = Input.inputString.ToUpper() ;
        switch (tecla) { 
            case "1": INIT ( ) ; break ;
            case "2": MIX ( ) ; break ;
            default: break ;
        }
    }
}

function INIT () {
    animation.Stop();
    status = "Stop" ;
}

function MIX () {
    status = "Mixing" ;

    // First layer. A smile in the mouth
    animation["mouthsmile"].layer = 0 ;
    animation["mouthsmile"].blendMode = AnimationBlendMode.Blend ;
    animation["mouthsmile"].weight = 1.0;
    animation.CrossFade("mouthsmile" , 0.7 , PlayMode.StopSameLayer) ;
    // Instead of .CrossFade() it could be .Play(),
    // so we don't need any blending yet

    // Second layer. Eyes closed
    animation["eyesclosed"].layer = 1 ;
                // AnimationBlendMode.Additive AnimationBlendMode.Blend
    animation["eyesclosed"].blendMode = AnimationBlendMode.Additive ;
            // This should be should be additive, because we want to
            // preserve the anims.-gestures of the other layers
    animation["eyesclosed"].weight = 1.0;
    animation.Sample() ; // ...give flying blind. When nothing works...
    animation.CrossFade("eyesclosed" , 0.7 , PlayMode.StopSameLayer) ;
}

// SOME RESOURCES
//  animation["mouthsmile"].time = 1.0 ;
//  animation[animLayer1mixA].normalizedTime = 1.0 ;

//  animation[animLayer1mixA].enabled = true;

//  animation.Play(animLayer0mixA) ;

//  animation.Blend(animLayer0mixA , 0.7 ) ;
//  animation.Blend(animLayer1mixA , 0.7 ) ;

I looked in the package and I think I found the problem. The page in the docs about Character Animation that I linked to state this about additive animations:

When making additive animations, Unity will calculate the difference between the first frame in the animation clip and the current frame.

In your animation clips, there is only one frame, or the second frame is identical to the first. So the deltas are zero and have no effect.

You need to construct the animation clips such that the first frame is neutral and another keyframe holds the actual additive deltas that you want to apply. From scripting you can then control the additive effect by setting the time of the AnimationState to 0 to have no effect or to the time of the other keyframe to get full effect.

You have the animation `eyesclosed` in a lower layer than the animation `mouthsmile`, so the `eyesclosed` animation is likely overwritten by the `mouthsmile` animation curves. Additive animations should be in higher layers than the animations they should add to in order to have any effect.

Higher layer means higher number, so layer 1 is higher than layer 0.

There's more information in the manual on the page about Character Animation.