Single animation freezes

Topics: Developer Forum
Apr 18, 2007 at 1:10 PM
Guess who's back?

Managed to pull out a single animation and play all of it with just a press of a button. An attack animation if you must know.

The animations that are looped works just fine. The run and walk animations work perfectly, but it's the non-looped attack animation that freezes after it is played. The model onscreen stabs with its knife then freezes in the start/end position for about three seconds.

Ideas?
Coordinator
Apr 18, 2007 at 4:35 PM
Sounds like one of the tracks of the animation contains extra frames, so that is delaying the rest of the animation.
Apr 19, 2007 at 10:15 AM
That is not the case.
We tried changing the XML document cause we figured that might be it. But the animation just froze on another spot.
Another thing we should mention is that we don't call frames. That doesn't work for us. We take the frame numbers given to us by the animators and divide it by 30 (the frame rate of the animation?) and hence gets the time. Ticks per second in the X-file is 4800.
Is this weird?
We debugged and found that after the animation is done it takes quite a while (the time the animation is frozen) before the animation state changes (stab -> idle).
One problem might be that the animation is shorter than the duration time, can we change the duration time? That might be a solution to the problem.
Coordinator
Apr 19, 2007 at 6:12 PM
So, the ElapsedTime just freezes for a while?
Coordinator
Apr 20, 2007 at 1:32 AM
Unfortunately, you'll need to give me more information for this one, like the xml file, or model, or both.
Apr 20, 2007 at 7:41 AM
http://medieteknik.bth.se/rosk05/project/Ich.rar
There. Knock yourself out.

All folders are part of our structure and I didn't want to change anything in the x-file.
The problem occurs with:
slash1
slash2
slash3

Working ones are:
Idle, walk and run. Although we are looping these....
Apr 20, 2007 at 7:52 AM
Update: We tried playing the run animation once instead of the slash1. And it worked perfectly fine. It didn't freeze for the last few frames so the problem must be with the slash animations. Don't know if you can help though. Could be another Goddamned export problem.
Coordinator
Apr 20, 2007 at 10:55 PM
Works perfectly fine for me... weird.

Are you subscribing to the AnimationEnded event?
Apr 23, 2007 at 8:16 AM
if (gPadState.Buttons.X == ButtonState.Pressed && combatState == "")
            {
                combatState = "slash1";
                Spirit_Slash1.ElapsedTime = 0;
                Spirit_Slash1.IsLooping = false;
                Spirit_Slash1.AnimationEnded += new AnimationEventHandler(Spirit_Slash1_AnimationEnded);
            }
 
        void Spirit_Slash1_AnimationEnded(AnimationController sender)
        {
            combatState = "";
        }
 
if (combatState == "slash1")
{
       foreach (BonePose p in poses)
       {
           p.CurrentAnimation = currentMoveAnimation();
           p.CurrentBlendAnimation = Spirit_Slash1;
           p.BlendFactor = 0.5f;
       }
}

Tried to move the AnimationEventHandler(SpiritSlash1AnimationEnded); to the last if-statement but it didn't do no diference.
Coordinator
Apr 24, 2007 at 5:15 AM
Edited Apr 24, 2007 at 5:21 AM
When an animation finishes and it is not looping, the model will remain in the end pose of the animation. If you are trying to change the pose after the animation has ended, you need to do it in the AnimationEnded method. For example, to set the animation to the default pose after the slash animation has completed, you would set your AnimationEnded method to the following:
        void Spirit_Slash1_AnimationEnded(AnimationController sender)
        {
            // Unhook event since the hook is recreated every time the X button is pressed
            sender.AnimationEnded -= Spirit_Slash1_AnimationEnded;
            combatState = "";
            foreach (BonePose p in poses)
            {
                p.CurrentAnimation = null;
                p.CurrentBlendAnimation = null;
            }
        }

You also should unhook the animation ended event when you are done with it (if you are creating a new event handler every time a user presses a button), as indicated in my code snippet.