problem in animation blending

Oct 9, 2010 at 5:32 PM
Edited Oct 9, 2010 at 5:54 PM

hi

i have an animated character which has some 5 animations like(stand in idle, sit, reach for tv remote, take remote(with remote stuck to the hand after reaching and getting back to sitting pose), and watch tv with remote)  

now my problem is to get these animations to blend one after the other. After going through the tutorials in xen , i used tutorial 11. so far the only problem im getting is the improper blend where the character blends to the next animation with a bone pose added in between...

and here is the code ....

public AnimationController animationController;
public AnimationInstance prevAnimation,currentAnimation;

animList.Add(animationController.AnimationIndex("stand_in_idle"));
animList.Add(animationController.AnimationIndex("sit_on_sofa"));
animList.Add(animationController.AnimationIndex("reach_for_remote"));
animList.Add(animationController.AnimationIndex("take_remote"));
animList.Add(animationController.AnimationIndex("watching_TV_with_remote"));

prevAnimation = animationController.PlayAnimation(animList[0], 0.5f, 0.5f); //PlayLoopingAnimation(animList[0]);

protected override void Update(UpdateState state)
{
            
  if (state.KeyboardState.KeyState.Right.OnPressed)
     playAnimation = true;
     
  if(playAnimation)
     {
          if ((!actor.prevAnimation.AnimationFinished))
          actor.prevAnimation.StopAnimation(0.5f);
          
          else 
             {
                 if (!actor.currentAnimation.Enabled)
                    actor.currentAnimation = actor.animationController.PlayAnimation(actor.animList[currentIndex], 0.5f, 0.5f);
                 
                animationTime = actor.currentAnimation.AnimationDuration;
                    totalElapsedTime = actor.currentAnimation.Time;

                if(totalElapsedTime > animationTime *0.5f)
                 {
                    actor.prevAnimation = actor.currentAnimation;
                    currentIndex += 1;
                    if (currentIndex >= 5)
                       currentIndex = 0;
                    actor.currentAnimation = actor.animationController.PlayAnimation(actor.animList[currentIndex], 0.5f, 0.5f);
                 }

              }
              actor.currentAnimation.Weighting = 1 - actor.prevAnimation.GetFadeScaledWeighting(state);
       }
        
}

so how do i blend between the animations thus avoiding bone pose.

and i have reset to currentIndex to zero just for testing purpose. actually the last animation needs to be looping for a while and then the character should come back to standing and stand idle pose ..