Jump Animation Jerky

Nov 18, 2007 at 5:43 PM
Edited Nov 19, 2007 at 4:29 PM
Hi, I have just finsihed making my dwarf walk and run and have now started to try and pad out all the other animations. I was wondering if i am doing the correct animation blending (and right jump code) for the jump animation

if (keyState.IsKeyDown(Keys.E))
{
if (dwarfPosition.Y == 0)
{
jump.ElapsedTime = 0;
jump.IsLooping = false;
jump.AnimationEnded += new AnimationEventHandler(jump_AnimationEnded);
Hello = true;
state = "jump";
}
}

void jump_AnimationEnded(object sender, EventArgs e)
{
// Add this in the crouch_AnimationEnded method
state = "jumpToIdle";
jump.AnimationEnded -= jump_AnimationEnded;
}

else if (state == "jump")
{
currentSpeed = WALK_SPEED;

if (Hello == true)
{
dwarfPosition.Y += 0.1f;
dwarfPosition.Y -= 0.1f;
dwarfPosition.Y = 0;
Hello = false;
}
RunController(dwarfAnimator, jump);
}

else if (state == "jumpToIdle")
{
blendFactor += .1f;
currentSpeed = (1f - blendFactor) * WALK_SPEED;
if (blendFactor >= 1)
{
float D;
D = dwarfPosition.Y - 0;
blendFactor = 1;
Hello = false;
state = "idle";
}
foreach (BonePose p in poses)
{
p.CurrentController = jump;
p.CurrentBlendController = idle;
p.BlendFactor = blendFactor;
}
}