This tutorial will show you how to use an XML file to split up your animation into different sections. This can be useful because many exporters do not allow you export multiple animations in one model.

This tutorial assumes you have a basic knowledge of XML. If you don't, do not worry, since XML is one of the easiest things you'll ever learn. Just do a Google on it.


  • Before you begin, note that when you change an XML file associated with a model, you must either select "rebuild all" on the project or force the model to be rebuilt by the content pipeline in some other way
  • To set up the project, follow the first three steps in the Making a Dwarf Realistically Walk and Run tutorial.
  • Delete dwarfmodelanimation.xml
  • Create a new XML file associated with dwarfmodel.x
  • Create a new animation node in the XML file. This says that you want to subdivide an animation into parts and replace the original animation with those parts:
    // Add this as the XML file root

    // Add this as a child of animation
  • Now add an <animationsubset> node as a child to <animation>. This node represents a new animation created from a time segment in the original:
    // Add this as a child of animation

  • We need to name our new animation. Let's name it "attack" by adding this as a child node of <animationsubset>:
    // Add this as a child of animationsubset
  • There are two ways to specify which time segment of the animation we want to use. If we added a <tickspersecond> node, we can specify the keyframe indices. If we know the start and end time, we can use that as well:
    // Add this as a child of animationsubset
    <startframe>127</startframe> OR <starttime>8.46666</starttime>
    <endframe>141</endframe>      OR <endtime>9.4</endtime>
  • You can add as many <animationsubset> nodes as you like.
  • Now, at this point select "rebuild all" on your project to make the content pipeline recognize that the XML file was changed
  • For our final step, lets display our animation in the project:
    // Add this to the LoadGraphicsContent method
    AnimationController attack = new AnimationController(
        this, dwarfAnimator.Animations["attack"]);
    foreach (BonePose p in dwarfAnimator.BonePoses)
        p.CurrentController = attack;

Last edited Mar 8, 2007 at 2:48 PM by dastle, version 12


conan2002 Nov 27, 2007 at 10:27 AM 
What's the mean of "<name>AnimationSet0</name>" in the tutorial's xml file.On the second line.
How does it work?