- Home /
Blended Animation offsetting
Hi community,
We are currently struggling with some ugly rotational offsetting on our character animations. This is happening when we play a run/idle loop, and then layer the fire(or any upperbody) animation on top. We are only blending the animation from the top spine bone upwards. It almost seems to be adding the rotation of the lower animation onto the rotation of the fire animation.
We can't seem to get over this hurdle, so I figured I'd try here! I did some searching on the site, but am not seeing anything specifically related to popping/offset animations when blending.
Any help is much appreciated, even if you can paste a hyperlink to a related solution!
Here is a the test script we use on the art side to check out our animations. There is some extra gui stuff in there, but the actual blending is being handled the same way:
public class AnimationTesting : MonoBehaviour {
public AnimationClip[] animClips;
public Transform mCharacterSpine;
private int animationPosition;
private int animationBlendPosition;
private bool canLoop;
private bool canBlend;
// Use this for initialization
void Start () {
for(int i = 0; i < animClips.Length; i++){
animation.AddClip(animClips[i], animClips[i].name);
}
}
// Update is called once per frame
void Update () {
}
void OnGUI(){
if(GUI.Button(new Rect(100,100,120,30), "Play")){
if(canBlend){
DoAnimationBlend(animClips[animationPosition].name, animClips[animationBlendPosition].name);
}
else{
animation.Play(animClips[animationPosition].name);
}
}
if(GUI.Button(new Rect(100,140,120,30), "Stop")){
animation.Stop();
}
if(GUI.Button(new Rect(100,180,120,30), animation[animClips[animationPosition].name].wrapMode.ToString())){
if(canLoop){
animation[animClips[animationPosition].name].wrapMode = WrapMode.Loop;
canLoop = false;
}
else{
animation[animClips[animationPosition].name].wrapMode = WrapMode.Once;
canLoop = true;
}
}
if(GUI.Button(new Rect(100,220,120,30), "Switch Animation")){
if(animationPosition == animClips.Length -1){
animationPosition = 0;
return;
}
animationPosition++;
}
GUI.Label(new Rect(80,50,220,30), "Current Animation : " + animClips[animationPosition].name);
if(GUI.Button(new Rect(400,100,120,30), "Blend")){
canBlend = !canBlend;
}
if(canBlend){
GUI.Label(new Rect(370,50,350,30), "Blend Above Spine Animation : " + animClips[animationBlendPosition].name);
if(GUI.Button(new Rect(400,140,150,30), "Switch Blend Animation")){
if(animationBlendPosition == animClips.Length -1){
animationBlendPosition = 0;
return;
}
animationBlendPosition++;
}
}
}
private void DoAnimationBlend(string baseAnim, string blendAnim){
animation[blendAnim].blendMode = AnimationBlendMode.Blend;
animation[blendAnim].AddMixingTransform(mCharacterSpine);
animation[blendAnim].layer = 2;
animation.SyncLayer(1);
animation.Play(baseAnim);
animation.Play(blendAnim);
}
}
EDIT: I should add that the upper body animations seem to look ok on an idle loop (where there is very little animation on the spine). Its when the body starts turning in sneaks or runs that the problem gets out of control.
If the animation on top spine is being totally overwritten, should it matter what is going on in the spine?(sorry if that's a dumb question, trying to wrap my head around it)
Ok, an update:
The animator was applying hip rotation to the com/root of the biped for the run, and the animations being stacked on top looked to be inheriting that transform.
We wiped those keys, and are trying to match the upper body pose of the run to the upper body pose of the fire animation to see if that fixes it.
It looks like we will need a separate set of upper body animations for when the character is crouching, as they all point down into the ground. Either that or we modify the crouch idle/runs to have a straight back... Any experiences with this situation out there?
I understand that this is an old thread, but maybe some solutions have been found? Have the same problem...
Your answer
![](https://koobas.hobune.stream/wayback/20220613061856im_/https://answers.unity.com/themes/thub/images/avi.jpg)