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?
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?
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.