Nerd Herder

Dean Johnson blogs about life on the XNA platform and tools team

Avatar animation updates

Avatar animation updates

  • Comments 5

Playback of one of the 31 built in animations is simple with the AvatarAnimation class. As I discussed in a previous post the BoneTransforms and Expression properties on the AvatarAnimation can be used with the AvatarRenderer.Draw method to animate an avatar. These two properties return the bone transforms and expression at a time in the animation based on the CurrentPosition property. CurrentPosition is a TimeSpan value that represents where in the animation playback is currently located. Valid values for CurrentPosition can be from zero to AvatarAnimation.Length.

There are two ways to set the CurrentPosition. The first and indirect way is to use the AvatarAnimation.Update(TimeSpan elapsedAnimationTime, bool loop) method that was used in the previous post. This allows the developer to specify the amount of time that has passed since the last update call. This delta can be provided by the gameTime.ElapsedGameTime parameter in the Game.Update method. It also allows the developer to specify if they want the animation to loop or not. The developer can also specify a negative elapsedAnimationTime value to play the animation backwards.

The other way is to use the CurrentPosition property directly. This allows the developer to implement any type of playback that they wish. While this is flexible it leaves managing looping and bounds checking to the developer.

Most developers will most likely use the Update method but the CurrentPosition property is exposed to allow for greater animation playback flexibility.

Page 1 of 1 (5 items)
Leave a Comment
  • Please add 6 and 6 and type the answer here:
  • Post
Translate This Page
Search
Archive