From Valve Developer Community
Revision as of 21:10, 14 September 2013 by Motherfat (talk | contribs) (Utility)
Jump to: navigation, search

The QC command $animation is used for $sequences with advanced features. The naming convention is confusing, and probably related to $animation becoming overburdened at some point between Source and GoldSrc, necessitating $sequence to be created.


Unlike $sequence, $animation only has one mode. All options are on the same line.

$animation <name> <skeletal animation smd> <options>
Tip.png Tip: Append _a to the end of $animation names to prevent confusion with $sequences.



Makes the sequence looping from the first frame.
fixuploop <int|pre-loop frame> <int|post-loop frame>
Finds the difference between the last and first frames of the animation and adjusts them to gently blends across the boundary.
startloop <int|local frame>
Resets the starting frame of a looping animation. This is useful when creating sequences that have multiple animations and the animations need to all run together in phase, but the source animations don't all quite match.
Looping animations, at least ones with movement, need the first and last frames to match position <ideally> as well as have movement. The reason for this is that studiomdl needs to tell the engine exactly how far to move the model between the "last" unique keyframe and the "first" keyframe when calculating those last tween frames. Since this last little 1/30th or 1/10th of a second distance is probably not exactly the same distance as the previous keyframe nor is probably exactly the same distance as the average per-frame movement, skipping the definition of the overlap can cause a hitch or foot slide during playback if studiomdl guesses wrong.
If for some serious reason the animator can't create the last frame overlap, then this option tells studiomdl to assume the movement is the average per-frame motion seen so far in the animation, and that it needs to create the overlapping frame itself.

World movement

walkframe <int|frame> <LX LY LZ LXR LYR LZR>
Makes the model move through the world, as defined by the movement of its root bone.
  • frame is the frame on which to end movement in the given direction. Unless your model changes direction half-way through the animation it should probably be set to the last one.
  • LX, LY etc. are the axes from which to extract movement. R stands for 'reverse'.
There can be up to 64 chained walkframes per $animation.


subtract <$animation/$sequence name> <int|frame>
subtract literally subtracts this animation from another. The subtracted animation must then be used used by a "delta" $sequence, at which point it will be added to (instead of replacing) the existing pose. This is one way to blend sequences together; see $weightlist for the other.
presubtract <$animation/$sequence name>
Subtracts the first frame of the specified animation. To do: Surely the same as subtract <anim> 0?
Subtracts either a linear or spline (s-curve) blend of the first and last frames.


alignto <goal_animation>
This will shift the current animation so that the root position of the first <local> frame matches the root position <X and Y axis only> of the first (local) frame of another animation. This is useful when animations don't start on the origin, or when you're cutting out just a small piece of a longer source animation and you need a quick way to get it aligned to a shared origin.
align <reference_animation> <X Y Z XR YR ZR> <reference_frame> <to_match_frame>
This is similar to alignto, except that you can specify how the two animations are to match, and that the <to match frame> on the animation is aligned with the <reference frame> of the <reference animation>. This is useful when aligning animations with vertical motion.
alignboneto <bone_name> <goal_animation>
Same as alignto, but will match the specified bone instead of the root.
match <animation>
Makes the first frame of the animation match the first frame of the specified animation, and then applies the difference between the two frames to all subsequence frames. This is mainly used to correct animations that are supposed to start at a common pose but don’t for some uncontrollable reason.
walkalignto <frame> <reference animation> <LX LY LZ LXR LYR LZR>
Like walkframe, but at extracts motion such that at <frame>, the model is aligned to the specified <reference animation>. This is useful when trying to extract the motion inside a animation that’s used to transition between two existing animations.
walkalign <frame> <reference animation> <LX LY LZ LXR LYR LZR> <reference frame> <to match frame>
Like walkalignto, but motion is calculated such that the <to match frame> matches the <reference frame> of the <reference animation>. This is useful when the last frame being used to extract motion over doesn’t quite match a goal animation, but a subsequent frame does.
rotateto <angle>
Finds the current direction of movement <uses the first movement if there are multiple pieces>, then rotates the animation so that the resulting movement is in the specified direction.


weightlist <string|$weightlist name>
This copies a predefined list of bone weights to the current animation. You can do this any number of times per animation, which can be useful since subsequent options subtract, match, and fixuploop options only operate on bones with weights > 0. The last specified weightlist option is the one the animation system uses when doing blending. Sequences that use multiple animations need to have all their source animations use the same weightlist or the results are undefined.
All animations default to a weightlist that assumes all bones have a weight of 1.0. Only the bones with a weight > 0 will have any influence over the animation. QC specified weightlists:
  • $weightlist no_hands "Bip01" 1.0 "Bip01 L Hand" 0.0 "Bip01 R Hand" 0.0
  • $weightlist head_n_arms "Bip01 Spine 2" 1.0
cmdlist <string|$cmdlist name>
Links to a $cmdlist of shared $animation options.
frames <int|start> <int|end>
Select a range of frames from the SMD to use. frame is also accepted.
Makes the animation additive, removes all the animation, zero’s out the weight list and sets a flag so that at run time the engine will skip all processing of the if it’s the only thing contributing to the sequence. This is handy for blended sequences where the "zero" position should have no effect on the model.
derivative <scale>
Turns the animation into the derivative of itself by simply subtracting the previous frame from each frame in the animation. The derivative can be automatically scaled to compensate for any fps issues.
fps <scale>
The speed of the animation (Default is usually 30).


To do: Related to inverse kinematics, but beyond that...
To do: These appear in QC files but their function is apparently unknown