Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I do not understand how to pause an animation of XNA. I can "Start" the animation of my model but not stop it. I use SkinningSample_4_0 sample dll

Here is my code to use.

Here is my code to use.

    protected override void LoadContent()
            //Model - Player
            model_player = Content.Load<Model>("Models\\Player\\models");
            // Look up our custom skinning information.
            SkinningData skinningData = model_player.Tag as SkinningData;

            if (skinningData == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");

            // Create an animation player, and start decoding an animation clip.
            animationPlayer = new AnimationPlayer(skinningData);

            AnimationClip clip = skinningData.AnimationClips["ArmLowAction_006"];



protected overide update(GameTime gameTime)
            animationPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
            KeyboardState key = Keyboard.GetState();

            //  If player don't move -> stop anim 
            if (!key.IsKeyDown(Keys.W) && !keyStateOld.IsKeyUp(Keys.S) &&           !keyStateOld.IsKeyUp(Keys.A) && !keyStateOld.IsKeyUp(Keys.D))
                //animation stop ? not exist ?
                isPlayerStop = true;
                if(isPlayerStop == true)
                     isPlayerStop = false;
share|improve this question
Could it be !key.IsKeyDown(Keys.W) ? Should it be !keyStateOld.IsKeyUp(Keys.W)? – Luis Estrada Dec 15 '12 at 16:57
Maybe, but this is only representative. My real problem is that the stop function does not exist. And I do not know how Stope – Mehdi Bugnard Dec 15 '12 at 17:23
Where is your animationPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity); – Luis Estrada Dec 15 '12 at 18:02
If you want it to stop, play an idle animation or a stop animation. – Luis Estrada Dec 15 '12 at 18:07
I added the function animationPlayer.update (... – Mehdi Bugnard Dec 15 '12 at 18:12
up vote 0 down vote accepted

I have finally found myself ^^

if (!key.IsKeyDown(Keys.W) && !key.IsKeyDown(Keys.A) && !key.IsKeyDown(Keys.D) && !key.IsKeyDown(Keys.S))
             //Stop animation for player walking
             animationPlayer.Update(new TimeSpan(0, 0, 0), true, Matrix.Identity);
             //Continue the animation 
             animationPlayer.Update(gameTime.ElapsedGameTime, true, Matrix.Identity);
share|improve this answer
The first animationPlayer.Update(... is not doing anything, you can just invert the bool expresion, and only call the second animationPlayer.Update(... when the user has a key down. – Luis Estrada Dec 16 '12 at 18:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.