Animation blending Torso and Run

Hi,

I have a shooting animation (with no lower body movement) and a running animation with all nodes moving.

To play the base running animation and overlay the shooting animation for the upper body, from reading the docs I thought all I had to do was the following:

public class TestAnimationBlend : MonoBehaviour
{
    public AnimationClip ClipA; // The shooting animation
    public AnimationClip Base; // The running animation

    public float BlendFactor;

    protected void Start()
    {
        animation[Base.name].layer = 1;
        animation.Play(Base.name);

        animation[ClipA.name].layer = 2;
    }

    protected void Update()
    {
        animation.Blend(ClipA.name, 1.0f);

    }
}

Unfortunately what happens is that the running animation stops completely and is replaced completely by the shooting animation.

I’m using a test mesh in Blender and there are no keys defined for the leg nodes of the shooting animation, so I’m wondering why it’s overwriting the running animation at all when I’m blending.

All animations are looping; if I comment out the Blend in the code above the run animation continues fine. What am I doing wrong here?

Hmmm, I’m rereading the animation docs again, and I think I misunderstood something.

If I want a character to be able to run and shoot independently, does this mean that I need to set up the following animations?

  1. A run animation with no upper body movement
  2. A run animation with only upper body movement
  3. A shoot animation with only upper body movement

…then I play the lower body run animation and use Additive blending to select which of the upper body animations I mix it with?

Is this correct?

Erm, sort of figured it out.

AddMixingTransform to kill off the transforms on the upper body of the running animation, another AddMixingTransform to kill off the lower body of the aiming animation, and then they’ll both blend happily together.

Hmmm, is there a reverse for AddMixingTransform, or do I just create two copies of the animation, one with the upper body killed off and one complete for when I want the entire run animation and don’t need the mixing?

You only need to use 2 animations, as you did at the first post. But use Additive mode for the shooting one.

http://unity3d.com/support/documentation/Manual/Character-Animation.html#LayerExample

Wouldn’t that still require 3 animation?

1 - Running animation with no upper body movement
2 - Running animation with no lower body movement
3 - Shooting animation with no lower body movement

I don’t see how you can use a shooting animation additively unless the bones that they’re adding to aren’t moving?

I wouldn’t recommend additive blending for this, you probably want the shooting animation to fully replace the run cycle, but only on the bones you specify right?

You’d only need two animations - a full body run, and a shooting animation with only upper body movement, and a mixing transform applied to the shoot anim so it only effect the bones you want (I imagine this would be the base of the spine, one node up from your COG.) You’d then put the firing animation in a higher animation layer, so it will override the run below it.

Yes! That’s exactly the setup I was looking for, and it works like a charm.

Thanks PirateNinjaAlliance!