This article's documentation is for anything that uses the Source engine. Click here for more information.

$animation

From Valve Developer Community
Jump to: navigation, search

$animation is a QC command available in all Source Source games. It is used for $sequences with advanced features.

Syntax

Unlike $sequence, $animation only has one mode. Options can be on the same line or defined in a class like form, with an opening { and closing }.

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

Options

Looping

loop
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.
fudgeloop
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 'rotation'.
There can be up to 64 chained walkframes per $animation.
<string|motion extract axis>
Movement animations are easier to create if the model actually moves forwards, but for playback in-game it must "walk on the spot". This command resolves the issue by stripping root bone translation from an animation. Accepted axes are:
  • X, Y, and Z
Warning.pngWarning:It looks like these axes completely ignore walkframe.
  • LX, LY and LZ - the root bone moves along the axis until the animation is half complete, then moves back to its original position.
    Tip.pngTip:You can extract motion from any combination of axes. Just put a space between each one.
  • LM - specifies that the motion extraction should be treated as linear
  • LQ - specifies that the motion extraction should be treated as quadratic

Blending

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.
Todo: Surely the same as subtract <anim> 0?
lineardelta
splinedelta
Subtracts either a linear or spline (s-curve) blend of the first and last frames.
worldspaceblend
Todo: Documentation

Alignment

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.
Todo: matchblend
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.

Utility

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.
noanimation
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).
compress <skip>
Turns a animation into a lower fps version of itself by only using every Nth frame. Automatically converts specified fps values into new equivalent.
numframes <frames>
Forces an animation to be a specified number of frames, either by clipping the animation or by duplicating the last frame until it has been padded with enough.
Note.pngNote:In source engine, animations start on frame 0. Numframes however, starts at 1. Using "numframes 30" will end up with the last frame in HLMV being frame 29. If you want to set a sequence to end on frame 30, you need "numframes 31"

Unknown

noautoik
autoik
Todo: Related to inverse kinematics, but beyond that...