Animation Blending Issue

So I’m having a bit of trouble with getting animations to blend together. Right now I’m blending the second animation like this:

animation.Blend("secondanimation", 1f, 0f);
animation["secondanimation"].blendMode = AnimationBlendMode.Additive;

This works really well, but when the first animation stops, the second one breaks outright. At the risk of overly simplifying the issue, is there an easy way to use additive blending for animations and not have them break when there are no normal animations playing?

Here’s what happens right now: 1. At 5 seconds, the second animation starts playing (the eyes move). At 11 seconds, the base animation stops. As you can see, it starts doing very strange things to the additive blended animation.

I’m not sure if I’m doing it wrong, or I’m missing something simple. There are a couple solutions that I could think of, like blending with an always running ‘idle’ animation, or keeping track of animations and shifting blending types, but neither sound like very good solutions. Are there any other ways to make it work well?

The “always play looping base” seems to be the most official answer.

What I got from the big animation docs was to use layers to control combining/fading. Unity wants to play only 1/layer (CrossFade stops all on same layer. I think ani.Blend is a hack to break that rule.) The vanilla solution seems to be:

o Layer 0 (the default layer) has all of the “forever” animations, like a looping walk, run, dance, idle, 2-frame looping “frozen” to keep Add happy, falling… . You’ll CrossFade into the new one, letting Unity automatically stop the old Layer0 one.

o Layer 2 (leaving layer 1 unused, just in case) has non-repeating animations, such as your entrance. Many of these will be some bones only (AddMixingTransform,) such as toss grenade. Some might be add animations. You can CrossFade these without thinking about the layer0 animation. Unity will auto-blend in and out for you.

o Layer 4 (saving layer 3 just in case) has all looping eyestalk animations, which will be either “eye bones only” or Adds

o Layer 5 has all non-looping eyestalk only, which can be played, will “cover” the looping eyestalks, but will revert back when done.

o Layer 6 has all front claws animations.

o etc…

So, play an actual knee-flexing idle (which is on L0) and CrossFade “entrance.” Entrance wins (on L2, a higher layer,) but when it finishes, it autofades into looping knee-flex. That idle isn’t just something to make Add happy – you want it playing invisibly in the background, so you’re auto-playing something after entrance finishes. In theory, Unity notices looping knee-flex is completely covered by entrance, so does no work computing anything for it until entrance ends.

Say you crossFade in the looping eyestalkWiggle after your 5 secs, but then you see a shark. All you do is CrossFade in eyestalkScared. That auto shuts off the eyeWiggle, but leaves entrance/idle unchanged.