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

$sequence: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Added missing information related to using a DMX instead of SMD for compiling a sequence)
No edit summary
 
(69 intermediate revisions by 22 users not shown)
Line 1: Line 1:
{{LanguageBar}}
{{toc-right}}
{{toc-right}}
{{tabsBar|main=gs|base=$sequence}}
{{this is a|QC command|name=$sequence}} It defines a [[skeletal animation]]. It can be used either on its own, or, to make use of Source's more advanced skeletal animation features, in conjunction with one or several <code>[[$animation]]</code>s.


The [[QC command]] <code>[[$sequence]]</code> defines a [[skeletal animation]]. It can be used either on its own, or, to make use of Source's more advanced skeletal animation features, in conjunction with one or several <code>[[$animation]]</code>s.
{{note|''All'' models that have any polygons must have at least one <code>$sequence</code>. If you don't actually want any movement, it's easiest to re-use your reference SMD. Models that solely use [[$includemodel]] do not require any <code>$sequences</code>.}}
 
:{{todo|What happens if no $sequences exist in the [[$includemodel]]?}}
{{note|''All'' models must have at least one <code>$sequence</code>. If you don't actually want any movement, it's easiest to re-use your reference SMD.}}


== Usage ==
== Usage ==


<code>$sequence</code> has two modes. One directly accesses a single [[skeletal animation]] (SMD or DMX), while the other needs intermediate <code>[[$animation]]</code>s.
<code>$sequence</code> has two modes. One directly accesses a single [[skeletal animation]] (SMD or DMX), while the other needs intermediate <code>[[$animation]]</code>s.
{{note|a DMX skeletal animation may only be used if the game that the model is being compiled for has dmxconvert. a list of games which have dmxconvert can be found on this page: [[DMX|DMX]]}}
{{note|a DMX skeletal animation may only be used if the game that the model is being compiled for includes the [[Dmxconvert]] util.}}


{{note|A <code>$sequence</code> can only see <code>$animation</code>s that come '''above''' it in the QC file.}}
{{note|A <code>$sequence</code> can only see <code>$animation</code>s that come '''above''' it in the QC file.}}


  $sequence <name> <skeletal animation [[Studiomdl Data|SMD]]/[[DMX|DMX]]> <simple options>
  $sequence <name> <skeletal animation [[Studiomdl Data|SMD]]/[[DMX]]> <simple options> { ''// opening brace '''must''' be on the same line as the command''
// braces can be ommitted if nothing is in them
<advanced options>
<[[Animation Events|events]]>
<simple options>
}


  $sequence <name> { ''// opening brace '''must''' be on the same line as the command''
  $sequence <name> <simple options> { ''// opening brace '''must''' be on the same line as the command''
  <[[$animation]] name(s)>
  <[[$animation]] name(s)>
  <advanced options>
  <advanced options>
Line 26: Line 34:
$modelname "weapons/shell.mdl"
$modelname "weapons/shell.mdl"
$cdmaterials "models/weapons/"
$cdmaterials "models/weapons/"
$body shell "shell-ref.smd"
$body shell "shell-ref"
$sequence idle "shell-idle.smd"
$sequence idle "shell-idle"
</syntaxhighlight>
</syntaxhighlight>


<syntaxhighlight lang=php>
<syntaxhighlight lang=php>
$animation a_strokechin "strokechin.smd" subtract idle 0
$animation a_strokechin "strokechin" subtract idle 0


$sequence strokechin {
$sequence strokechin {
Line 49: Line 57:
node "running"
node "running"
}
}
</syntaxhighlight>
A $sequence may also have all of its data on a single line to make the QC smaller to scroll through.
<syntaxhighlight lang=php>
$Sequence "idle"  a_idle_closed "ACT_CEILING_TURRET_CLOSED_IDLE" 1 node "close" fps 1 loop hidden
</syntaxhighlight>
</syntaxhighlight>


Line 56: Line 69:


; <code><[[string]]|name></code>
; <code><[[string]]|name></code>
: The name of the animation. Will appear in HLMV, Hammer, etc.
: Required. The name of the animation. Will appear in HLMV, Hammer, etc. Used by some entities (e.g. [[prop_dynamic]]) instead of the index.
; <code>origin <x> <y> <z></code>
 
; <code><[[string]]|Skeletal animation file></code>
: Required if not using [[$animation]]. Path to the <code>$sequence</code>'s source file. ''By including this, you tell studiomdl that you are using the simple version of the command.''
 
; <code>frame <[[int]]|start frame> <[[int]]|end frame></code>
; <code>frames <[[int]]|start frame> <[[int]]|end frame></code>
: Specifies a range of frames to extract from the source animation. Useful for trimming off frames not used in a particular animation.
:: For example, if the source animation contains 80 frames (range of 0-79) but this animation should only play the last 30 frames, then <code>frames 50 79</code> will load only those frames.
: Can also be used to extract a single frame of animation by making the start and end frames match.
: <code>frames</code> and <code>frame</code> are interchangeable.
: {{warning|All frame numbers used elsewhere in the sequence (e.g. [[Animation Events|animation events]]) are relative to <code>start frame</code>.}}
: {{bug|In a [[blend sequence|blended sequence]], this option will only affect the first specified animation.}}
: {{fix|Instead of including this option in the $sequence itself, you can separate each animation into its own [[$animation]] above the sequence, and use the <code>frame/frames</code> parameter on each of those to specify their intended frame range.}}
 
; <code>numframes <[[int]]|frames></code>
: 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.
: If used in conjunction with <code>frame/frames</code>, then it will respect the start frame. When it specifies fewer frames, it will cut the animation short. However, when it specifies more frames, it will repeat the last frame to meet the frame limit.
:: For instance, <code>frames 10 12 numframes 12</code> will result in the animation extracting only frames 10 through 12, but frame 12 will be repeated to meet the 12 total frames specified, as if it was the real end of the animation.
{{note|In the source engine, animations start on frame 0, but <code>numframes</code> starts at 1 since it specifies the "number" of frames. Setting <code>numframes</code> to 30 will capture only 30 frames, which means a range of 0-29. If you intend to make an animation end on frame 30, you need to set <code>numframes</code> to 31, since it will then capture 31 total frames (a range of 0-30).}}
 
; <code>origin <[[float]]|x> <[[float]]|y> <[[float]]|z></code>
: Adjusts the position of the animation within its own local space.
: Adjusts the position of the animation within its own local space.
; <code>rotate <x> <y> <z></code>
 
; <code>angles <[[float]]|x> <[[float]]|y> <[[float]]|z></code>
: Adjusts the rotation of the animation within its own local space.
: Adjusts the rotation of the animation within its own local space.
; <code>angles</code>
 
: {{todo|Documentation}}
; <code>rotate <[[float]]|angle></code>
: Identical to <code>angles</code>, but it only rotates along the Z axis.
 
; <code>scale <[[float]]|scale></code>
; <code>scale <[[float]]|scale></code>
: Multiplies the size of the skeleton in this sequence. Negative values are accepted.
: Multiplies the size of the skeleton in this sequence. Negative values are accepted.
; <code>reverse</code> {{CSGO add|}}
 
; <code>reverse</code> {{CSGO|add}}{{also|{{gmod}}}}
: Reverses the animation.
: Reverses the animation.
; <code><string|Skeletal animation SMD></code>
 
: Path to the $sequence's source SMD. ''By including this, you tell studiomdl that you are using the simple version of the command.''
; <code>loop</code>
; <code>loop</code>
: Has three effects:
: Marks the sequence as being a looping animation that will play continuously, and causes StudioMDL to perform some cleanup on the first & last frames.
:* Causes the sequence to repeat endlessly until stopped.
: The sequence will no longer be able to interrupt itself, if asked to play while currently playing.
:* Prevents the sequence from restarting if triggered while already playing.
 
:* Causes studiomdl to perform some cleanup between the first and last frames.
; <code>hidden</code>
; <code>noforceloop</code>
: Prevents the $sequence from being listed in user interfaces. Useful for sequences which serve only as layers of others.
 
; <code>noanimation</code>
: Forces the sequence to have a zero-weight animation. Effectively ignores <code>frame/frames</code>, but will respect <code>numframes</code>.
: Equivalent to using a [[$weightlist]] that removes the weight of all bones. Useful for creating special composite sequences comprised only of added or blended layers.
 
; <code>fps <[[float]]|frames per second></code>
: Override the framerate of the animation. If unspecified, defaults to <code>30</code>.
: {{note|These are ''animation'' frames - not screen frames!}}
: {{bug|In {{gldsrc}}, using a negative framerate does '''not''' cause the animation to play in reverse; instead the animation will break incredibly.<br>In {{src}}, the [[StudioMDL_(Source)|model compiler]] will just abort when the FPS is less than 0.}}
 
; <code><[[string]]|motion extract axis></code>
: 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.
:: You can add <code>walkframe <[[int]]|endframe of motion extraction></code> at the same line before specifying axis to limit motion extraction for specific part of animation.
:: {{note|Extraction always starts from the beginning of animation or from the last specified <code>walkframe</code>, and ends at the specified frame. To create a delay, use <code>walkframe</code> without specifying axis.}}
:: {{tip|You can add several <code>walkframe</code> to get a more accurate result.}}
<syntaxhighlight lang=php highlight=7,8,9>
$sequence sword_attack {
"knight_anims/sword_attack"
ACT_SPECIAL_ATTACK1 1
fadein 0.2
fadeout 0.2
fps 30
walkframe 10 LX LY LZR //motion extraction from the start to 10 frame
walkframe 30 LX LY LZR //motion extraction from 10 to 30 frame
LX LY LZR //motion extraction from 30 frame until the end of animation
}
</syntaxhighlight>
:Accepted axes are:
:* X, Y, Z, XR, YR, and ZR - R stands for 'rotation'.
::{{warning|It looks like these axes completely ignore <code>walkframe</code>.}}
:* LX, LY, LZ, LXR, LYR, and LZR - the root bone moves along the axis until the animation is half complete, then moves back to its original position. {{tip|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
: This command is also available on [[$animation]]s.
 
; <code>activity <[[string]]|name> <[[float]]|weight></code>
: Links the sequence to an [[activity]].
: {{tip|If an activity name starts with "ACT_" then the activity keyword can be removed. When ACT_ is seen, it is implicitly an activity.}}
: If more than one <code>$sequence</code> has the same [[activity]], then the <code>weight</code> specifies how likely this sequence is to be picked when that activity is called. The odds of any particular <code>$sequence</code> playing is simply its weight over the sum of all other weights.
:: For example, if a <code>$sequence</code> named <code>swing_a</code> has a weight of 2, and another <code>$sequence</code> named <code>swing_b</code> has a weight of 1, then there is a 2/3 chance for <code>swing_a</code> to play instead of <code>swing_b</code>.
:: {{note|If there is only one sequence tied to the activity, then its weight is irrelevant.}}
 
; <code>autoplay</code>
: Makes the sequence play at all times, on top of any other animations, no matter what the model is doing. Good for blended breathing animations and other automated motion. If a model has multiple <code>autoplay</code> $sequences, they’re layered in the order that they appear in the QC. {{warning|Don't use this for an animation that might be played normally, or you'll end up with it playing twice and the motion doubling up.}}
 
; <code>addlayer <[[string]]|other $sequence name></code>
: Play another sequence on top of this one. The animations begin and end together, so discrepancies in their total run time (framerate * number of frames) will proportionately affect the added layer's framerate, if applicable. The other $sequence ''doesn't'' have to be above the current one.
: This is generally used to add either <code>delta</code>-ed layers such as [[Blend sequence|aim matrices]] or specially [[$weightlist|weighted]] layers that only affect specific bones.
: The other <code>$sequence</code> can be [[$declaresequence|declared ahead of time]] if it will be [[$includemodel|imported at runtime.]]
 
; <code>blendlayer <[[string]]|other $sequence name> <[[int]]|startframe> <[[int]]|peakframe> <[[int]]|tailframe> <[[int]]|endframe> [options...]</code>
: Similar to <code>addlayer</code>, but the new sequence only plays over specified frames, and it accepts a number of options.
: The animation starts at 0% intensity on <code>startframe</code>, reaches 100% intensity on <code>peakframe</code>, starts to fade away on <code>tailframe</code>, and fully fades out on <code>endframe</code>.
: Options:
:; <code>spline</code>
:: Instead of fading the layer linearly, fade it with a spline curve.
:; <code>xfade</code>
:: The layer will only fade in and not back out.
:; <code>poseparameter <[[string]]|name></code>
:: Allows a [[$poseparameter|pose parameter]] to control the fading of the layer instead of the parent <code>$sequence</code>'s frame. When this option is present, the frame range is instead used to determine how the pose parameter's value should make the layer fade in/out.
::: Example: <code>blendlayer aimmatrix -1 0 0 1 poseparameter move_x</code>
<pre>
param value: -2.000 -1.500 -1.000 -00.80 -00.60 -00.40 -00.200 000.00 00.200 00.400 00.600 00.800 1.0000 1.5000 2.0000
layer weight: 0.000% 0.000% 0.000% 20.00% 40.00% 60.00% 80.00% 100.0% 80.00% 60.00% 40.00% 20.00% 0.000% 0.000% 0.000%
</pre>
:::: These values will change when making use of the <code>spline</code> option, but will still start and end at the same time.
:; <code>noblend</code>
:: Causes the layer to stop fading in/out entirely and always be at 100% intensity while active. This also makes the layer ignore sequence transitions.
:: {{note|If a constant intensity is needed but ignoring sequence transitions isn't desirable, the peak and tail frames should be set to the start and end frames respectively instead. That will make the command equivalent to <code>addlayer</code>, but with a specific frame range.}}
:; <code>local</code>
:: Marks the layer as a local context sequence. This blends the layer with the main sequence ''before'' the main sequence's keyframes are actually applied to the bones. This is mainly useful for sequence transitions, which otherwise fade layers separately from the main sequence.
: {{warning|Unless the blended sequence has the <code>realtime</code> option, the blended sequence's framerate will be adjusted relative to the parent sequence so that it starts on <code>startframe</code> and ends on <code>endframe</code>. For example, if both the parent and blended sequences play at 30 frames per second and last for 30 frames, but the blended sequence only plays during frames 5 through 20 (a total of 15 frames, only ''half'' of its original length), then the blended sequence will play at 60 frames per second ('''twice''' its original framerate!) so that it can start on frame 5 and end on frame 20.}}
 
; <code>worldspace</code>
: When used as a layer, calculates the bone positions in worldspace instead of relative to the parent animation. {{note|When <code>weightlist</code> is used, the weight of the root bone must not be 0.}}
: {{todo|Does it actually do anything?}}
 
; <code>worldspaceblend</code>
: {{todo|Documentation}}
: {{todo|Documentation}}
;<code>hidden</code>
 
:Prevents the $sequence from being listed in user interfaces. Useful for sequences which serve only as layers of others.
; <code>snap</code>
;<code>fps <[[float]]|frames per second></code>
: Remove all blending when transitioning to this animation. This is useful for reaction animations that are the result of sudden and violent changes in the model's state, such as a creature flinching or a weapon firing.
:Override the speed at which the animation plays. Note that these are ''animation'' frames - not screen frames! {{TODO|Performance implications; sparse keyframes &#61; CPU load, dense keyframes &#61; memory load?}}
: {{note|This may look jarring and buggy on animations that repeat quickly. Such as in firing animations of rifles. As it would reset to the first frame where the gun is not yet affected by recoil without any fade. Therefore a <code>fadein 0.05</code> might be a better alternative.}}
;<code><[[string]]|motion extract axis></code>
 
: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:
; <code>realtime</code>
:*X, Y, and Z
: Normally, when a sequence is asked to play, it will start at frame 0, and can be subjected to FPS changes by any parent sequence that's adding it via <code>blendlayer</code>. This option changes this so that the animation is instead synchronized with the map clock. Useful for adding layers that shouldn't play at the same rate as their parent $sequence, such as breathing.
:*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|You can extract motion from any combination of axes. Just put a space between each one.}}
: {{warning|<b><i>All models</i> playing this animation will be synchronized to the map clock!</b> You may want to use this sparingly, ideally on models that are only seen once in the game, such as viewmodels.}}
: This command is also available on [[$animation]]s.
 
;<code>activity <[[string]]|name> <[[float]]|weight></code>
; <code>fadein <[[float]]|seconds></code>
:Links the sequence to an [[activity]]. The name should be one recognised by the target NPC's code. <code>Weight</code> modifies how likely this particular sequence is to be picked when the activity is called; if a $sequence has a weight twice that of another, it is twice as likely to be used. If an activity name starts with "ACT_" then the activity keyword can be removed. When ACT_ is seen, it is implicitly an activity. {{tip|If there is only one sequence tied to the activity, use a weight of -1.}}
: Override how long this animation spends fading in. Default is 0.2.
;<code>autoplay</code>
: {{note|<code>fadein 0</code> achieves the same effect as <code>snap</code>, but {{hlmv|4}} will not recognize it as a snap when automatic blending is enabled, making <code>snap</code> necessary.}}
:Makes the $sequence play at all times, on top of any other animations, no matter what the model is doing. Good for blended breathing animations and other automated motion. If a model has multiple <code>autoplay</code> $sequences, they’re layered in the order that they appear in the QC. {{warning|Don't use this for an animation that might be played normally, or you'll end up with it playing twice and the motion doubling up.}}
 
;<code>addlayer <[[string]]|other $sequence name></code>
; <code>fadeout <[[float]]|seconds></code>
:Play another sequence (probably <code>delta</code>-ed) at the same time as this one. The animations begin and end together. The other $sequence ''doesn't'' have to be above the current one.
: Override how long this animation spends fading out. Default is 0.2.
;<code>blendlayer <[[string]]|other $sequence name> <[[int]]|startframe> <[[int]]|peakframe> <[[int]]|tailframe> <[[int]]|endframe> [spline] [xfade]</code>
:{{tip|You can calculate the exact frame at which the fadeout should begin by dividing that frame number by your FPS, and then subtracting that number from the result of dividing the whole framecount by the FPS.<br>Example: animation has a total of 200 frames, fps is 120, desired "fadeout" frame is 150 which means the calculation is: 150/120 is 1.25, then 200/120 is 1.666, then 1.666-1.25 is 0.41. 0.41 is the fadeout you want to make the fade appear on frame 150.}}
:Similar to <code>addlayer</code>, but the new $sequence only plays over specified frames.
 
:*<code>peakframe</code> is when the animation reaches 100% intensity, and <code>tailframe</code> is when it starts to fade away.
; <code>weightlist <[[string]]|weightlist name></code>
:*The <code>spline</code> option converts the linear start-peak and tail-end fades of the $sequence to a spline curve.
: Selects a [[$weightlist|weightlist]] to apply to this sequence.
:*{{TODO|Behaviour of xfade.}}
: If a [[$defaultweightlist|default weightlist]] is used, this will override it with the specified weightlist for this animation.
;<code>snap</code>
 
:Remove all blending when transitioning to this animation. This is useful for reaction animations that are the result of sudden and violent changes in the model's state, such as a creature flinching or a weapon firing.
; <code>worldrelative</code> {{csgo|since}}
;<code>realtime</code>
: {{todo|Documentation}}
:Ignore the $sequence's <code>fps</code> and time it with the global system clock instead. Useful when adding layers that shouldn't play at the same rate as their parent $sequence.
 
;<code>fadein <[[float]]|seconds></code>
; <code>localhierarchy <[[string]]|bone name> <[[string]]|new parent name> [range <[[int]]|startframe> <[[int]]|peakframe> <[[int]]|tailframe> <[[int]]|endframe>]</code>
:Override how long this animation spends fading in. Default is 0.2.
: Changes a bone's parent for this animation only. "" can be used to remove the parent of a bone.
;<code>fadeout <[[float]]|seconds></code>
: This is primarily useful for ensuring that a bone blends correctly. As an example, if a weapon is normally held in the right hand, but during this animation it's held in the left hand, it will blend as if it were being held by the right hand. This option can then be used to make it blend relative to the left hand instead, which will remove the jittering caused by blending.
:Override how long this animation spends fading out. Default is 0.2.
: <code>range</code> is optional, and requires four frame numbers that specify how the hierarchy should be blended over the specified frames.
;<code>weightlist <[[string]]|weightlist name></code>
: {{note|This does not affect animations during transitions, making <code>snap</code> necessary.}}
:Selects a [[$weightlist]] to apply to this sequence.
 
;<code>localhierarchy "<bone name>" "<parent bone name>"</code>
; <code>compress <[[int]]|frameskip></code>
:Changes a bone's parent for this animation only. "" can be used to remove the parent of a bone.
: Saves only every <code>frameskip</code> frame of the input animation, starting at frame 0. A value of 1 or below does nothing.
:{{note|This does not affect animations during transitions, making <code>snap</code> necessary.}}
 
;<code>compress</code>
; <code>posecycle <[[string]]|pose parameter></code>
:{{todo|Documentation}}
: Makes the specified [[$poseparameter|pose parameter]] control the animation frame instead of the specific animation that should play in a [[blend sequence]].
: You can use it to more easily create a detailed (but entirely linear) blend sequence. Not often used in the SDK, but is faster to set up & has no limit on the number of blended [[$animation|$animations]].
: The pose parameter's min & max values will determine where the animation starts & ends. Below is an example of a parameter with a range of -180 to 180, being used on an animation with 9 total frames (range 0-8):
<pre>
param value: -180.0 -135.0  -90.0  -45.0    0.0  45.0  90.0  135.0  180.0
anim frame:    0      1      2      3      4      5      6      7      8
</pre>
: {{warning|If you don't forward-declare the pose parameter with <code>$poseparameter</code>, [[StudioMDL_(Source)|StudioMDL]] will still generate a pose parameter just like <code>blend</code>, but it will have an invalid range.}}


=== Advanced ===
=== Advanced ===
Line 116: Line 237:
In addition to all simple options:
In addition to all simple options:


;<code>delta</code>
; <code>delta</code>
:Tells Source that the <code>[[$animation]]</code>s referenced in this sequence have all been <code>subtract</code>ed. The $sequence will be played on top of whatever sequences are currently playing, rather than overriding them. {{warning|Using this with an <code>$animation</code> that hasn't been <code>subtract</code>ed has bad results!}}
: Tells Source that the <code>[[$animation]]</code>s referenced in this sequence have all been <code>subtract</code>ed. The $sequence will be played on top of whatever sequences are currently playing, rather than overriding them. {{warning|Using this with an <code>$animation</code> that hasn't been <code>subtract</code>ed has bad results!}}
;<code>predelta</code>
 
:The compliment to the "presubtract" command, this tells the animation compositing system to add the current bone setup on top of a different frame of reference instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
; <code>predelta</code>
;<code>blend <[[string]]|name> <[[float]]|min value> <[[float]]|max value></code>
: The compliment to the "presubtract" command, this tells the animation compositing system to add the current bone setup on top of a different frame of reference instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
;<code>blendwidth <[[int]]|width></code>
 
:See [[Blend sequence]].
; <code>blend <[[string]]|name> <[[float]]|min value> <[[float]]|max value></code>
;<code>ikrule</code>
; <code>blendwidth <[[int]]|width></code>
:See [[$ikchain]]
; <code>blendref <[[string]]|name></code>
;<code>iklock</code>
; <code>blendcomp <[[string]]|name></code>
Freezes the bone specified in an [[$ikchain]]
; <code>blendcenter <[[string]]|name></code>
:See [[$ikchain]]
; <code>calcblend <[[string]] name> <[[string]] attachment> <XR YR ZR></code>
: See [[Blend sequence]].
 
; <code>ikrule</code>
: See [[$ikchain]].
 
; <code>iklock</code>
: Freezes the bone specified in an [[$ikchain]].
: See [[$ikchain]].
 
; <code>activitymodifier</code> <[[string]]|modifier> {{since|{{as}}|}} {{also|{{src13mp}}{{tf2branch}}}}
: {{todo|Documentation}}


=== Miscellaneous ===
=== Miscellaneous ===


;node (name)
; <code>node <[[string]]|name></code>
:Tags the sequence as belonging to a point on the sequence transition graph table. This is for animations which don’t change graph state, such as looping animations. Multiple sequences can be at the same entry in the graph table, at which point they won’t need transition animations to move between each other.
: Tags the sequence as belonging to a point on the sequence transition graph table. This is for animations which don’t change graph state, such as looping animations. Multiple sequences can be at the same entry in the graph table, at which point they won’t need transition animations to move between each other.
:Alternatively, you can have them at different points and expressly skip transitions (see $skiptransition). Sequences with no declaration are assumed at the root node and the transition graph assumes any sequence can move from the root node or to the root node without a intermediate transition.  
: Alternatively, you can have them at different points and expressly skip transitions (see $skiptransition). Sequences with no declaration are assumed at the root node and the transition graph assumes any sequence can move from the root node or to the root node without a intermediate transition.  
;transition (from) (to)
; <code>transition <[[string]]|from> <[[string]]|to></code>
:This specifies that the animation enters from one point on the node graph and exits at another point. This is used to play transitional sequences such as walk_to_stand, run_to_crouch, etc.  
: This specifies that the animation enters from one point on the node graph and exits at another point. This is used to play transitional sequences such as walk_to_stand, run_to_crouch, etc.  
;rtransition (name1) (name2)
; <code>rtransition <[[string]]|name1> <[[string]]|name2></code>
:Same as transition, but flags the sequence as able to be run in reverse order. This was used by the tentacle in HL1 but I don’t recommend it be used except in special cases.  
: Same as transition, but flags the sequence as able to be run in reverse order. This was used for the [[monster_tentacle (GoldSrc)|Tentacle]] in {{hl|4}}; except for special cases, using this isn't recommended.{{inline note|name=Why?}}
;exitphase (phase)
; <code>exitphase <[[string]]|phase></code>
:When transitioning between looping animations, such as "stand_to_run", this tells the movement system where to start the next sequence, assuming it’s looping. It’s also assumed that you’ve made all the sequences that share the next node to be phase matched (see startloop).  
: When transitioning between looping animations, such as "stand_to_run", this tells the movement system where to start the next sequence, assuming it’s looping. It’s also assumed that you’ve made all the sequences that share the next node to be phase matched (see startloop).  
;$skiptransition (name1) (name2) [(name3) ...]
{{warning|Does nothing, not implemented by the game}}
:This adds a rule to the transition graph to allow direct movement between all the named nodes. This is useful for transitions between unique named nodes that that may not require any specific intermediate animation. This is how to avoid the transition graph from forcing "walk" to "run" to instead be a "walk" to "stand" to "run" transition.  
; <code>$skiptransition <[[string]]|name1> <[[string]]|name2> <[[string]]|name3> ...]</code>
;keyvalues { [stuff] }
: This adds a rule to the transition graph to allow direct movement between all the named nodes. This is useful for transitions between unique named nodes that that may not require any specific intermediate animation. This is how to avoid the transition graph from forcing "walk" to "run" to instead be a "walk" to "stand" to "run" transition.  
:Add a keyvalue block (see [[$keyvalues]]) to a specific sequence. This is how gestures get set up for Faceposer (apex, tail, etc)
; <code>keyvalues { <stuff> }</code>
:Add a keyvalue block (see [[$keyvalues]]) to a specific sequence. This is used for [[Creating Faceposer gestures|setting up gestures for Faceposer]].


== Events ==
== Events ==
A $sequence can have certain [[Animation Events]] occur at different times during the animation, like so:
<source lang=c>
$sequence tentacle_grab "tentacle_grab" {
  fps 15
  { event 1000 1 }
  { event 1004 4 "*scientist/scream02.wav" }
  { event 1003 18 "smash" }
  { event 1004 65 "*scientist/c1a4_sci_tent.wav" }
}</source>
The format for each event is this:
<source lang=c>{ event <event name or ID> <frame of animation> <optional argument> }</source>


Events are available when using <code>[[$animation]]</code>s. See [[Animation Events]].
Each sequence can have up to 1024 animation events with default studiomdl.exe


[[Category:QC Commands|s]]
The optional argument can be up to 64 bytes/characters long.
Event name can be up to 128 bytes/characters long.

Latest revision as of 17:45, 3 August 2025

English (en)中文 (zh)Translate (Translate)

$sequence is a QC command available in all Source Source games. It defines a skeletal animation. It can be used either on its own, or, to make use of Source's more advanced skeletal animation features, in conjunction with one or several $animations.

Note.pngNote:All models that have any polygons must have at least one $sequence. If you don't actually want any movement, it's easiest to re-use your reference SMD. Models that solely use $includemodel do not require any $sequences.
Todo: What happens if no $sequences exist in the $includemodel?

Usage

$sequence has two modes. One directly accesses a single skeletal animation (SMD or DMX), while the other needs intermediate $animations.

Note.pngNote:a DMX skeletal animation may only be used if the game that the model is being compiled for includes the Dmxconvert util.
Note.pngNote:A $sequence can only see $animations that come above it in the QC file.
$sequence <name> <skeletal animation SMD/DMX> <simple options> {		// opening brace must be on the same line as the command
	// braces can be ommitted if nothing is in them
	<advanced options>
	<events>
	<simple options>
}
$sequence <name> <simple options> {		// opening brace must be on the same line as the command
	<$animation name(s)>
	<advanced options>
	<events>
	<simple options>
}

Examples

$modelname		"weapons/shell.mdl"
$cdmaterials		"models/weapons/"
$body		shell	"shell-ref"
$sequence idle	"shell-idle"
$animation a_strokechin "strokechin" subtract idle 0

$sequence strokechin {
	a_strokechin
	delta
}
$sequence run_holding_all {
	a_runS a_runSE a_runE a_runNE a_runN_SMG a_runNW a_runW a_runSW a_runS

	blendwidth 9
	blend move_yaw -180 180
	addlayer layer_run_holding
	ACT_RUN_RIFLE 1
	node "running"
}

A $sequence may also have all of its data on a single line to make the QC smaller to scroll through.

$Sequence "idle"  a_idle_closed "ACT_CEILING_TURRET_CLOSED_IDLE" 1 node "close" fps 1 loop hidden

Options

Simple

<string|name>
Required. The name of the animation. Will appear in HLMV, Hammer, etc. Used by some entities (e.g. prop_dynamic) instead of the index.
<string|Skeletal animation file>
Required if not using $animation. Path to the $sequence's source file. By including this, you tell studiomdl that you are using the simple version of the command.
frame <int|start frame> <int|end frame>
frames <int|start frame> <int|end frame>
Specifies a range of frames to extract from the source animation. Useful for trimming off frames not used in a particular animation.
For example, if the source animation contains 80 frames (range of 0-79) but this animation should only play the last 30 frames, then frames 50 79 will load only those frames.
Can also be used to extract a single frame of animation by making the start and end frames match.
frames and frame are interchangeable.
Warning.pngWarning:All frame numbers used elsewhere in the sequence (e.g. animation events) are relative to start frame.
Icon-Bug.pngBug:In a blended sequence, this option will only affect the first specified animation.  [todo tested in ?]
Note.pngFix:Instead of including this option in the $sequence itself, you can separate each animation into its own $animation above the sequence, and use the frame/frames parameter on each of those to specify their intended frame range.
numframes <int|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.
If used in conjunction with frame/frames, then it will respect the start frame. When it specifies fewer frames, it will cut the animation short. However, when it specifies more frames, it will repeat the last frame to meet the frame limit.
For instance, frames 10 12 numframes 12 will result in the animation extracting only frames 10 through 12, but frame 12 will be repeated to meet the 12 total frames specified, as if it was the real end of the animation.
Note.pngNote:In the source engine, animations start on frame 0, but numframes starts at 1 since it specifies the "number" of frames. Setting numframes to 30 will capture only 30 frames, which means a range of 0-29. If you intend to make an animation end on frame 30, you need to set numframes to 31, since it will then capture 31 total frames (a range of 0-30).
origin <float|x> <float|y> <float|z>
Adjusts the position of the animation within its own local space.
angles <float|x> <float|y> <float|z>
Adjusts the rotation of the animation within its own local space.
rotate <float|angle>
Identical to angles, but it only rotates along the Z axis.
scale <float|scale>
Multiplies the size of the skeleton in this sequence. Negative values are accepted.
reverse Counter-Strike: Global Offensive(also in Garry's Mod)
Reverses the animation.
loop
Marks the sequence as being a looping animation that will play continuously, and causes StudioMDL to perform some cleanup on the first & last frames.
The sequence will no longer be able to interrupt itself, if asked to play while currently playing.
hidden
Prevents the $sequence from being listed in user interfaces. Useful for sequences which serve only as layers of others.
noanimation
Forces the sequence to have a zero-weight animation. Effectively ignores frame/frames, but will respect numframes.
Equivalent to using a $weightlist that removes the weight of all bones. Useful for creating special composite sequences comprised only of added or blended layers.
fps <float|frames per second>
Override the framerate of the animation. If unspecified, defaults to 30.
Note.pngNote:These are animation frames - not screen frames!
Icon-Bug.pngBug:In GoldSrc, using a negative framerate does not cause the animation to play in reverse; instead the animation will break incredibly.
In Source, the model compiler will just abort when the FPS is less than 0.  [todo tested in ?]
<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.
You can add walkframe <int|endframe of motion extraction> at the same line before specifying axis to limit motion extraction for specific part of animation.
Note.pngNote:Extraction always starts from the beginning of animation or from the last specified walkframe, and ends at the specified frame. To create a delay, use walkframe without specifying axis.
Tip.pngTip:You can add several walkframe to get a more accurate result.
$sequence sword_attack {
	"knight_anims/sword_attack"
	ACT_SPECIAL_ATTACK1 1
	fadein 0.2
	fadeout 0.2
	fps 30
	walkframe 10 LX LY LZR //motion extraction from the start to 10 frame
	walkframe 30 LX LY LZR //motion extraction from 10 to 30 frame
	LX LY LZR //motion extraction from 30 frame until the end of animation
}
Accepted axes are:
  • X, Y, Z, XR, YR, and ZR - R stands for 'rotation'.
Warning.pngWarning:It looks like these axes completely ignore walkframe.
  • LX, LY, LZ, LXR, LYR, and LZR - 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
This command is also available on $animations.
activity <string|name> <float|weight>
Links the sequence to an activity.
Tip.pngTip:If an activity name starts with "ACT_" then the activity keyword can be removed. When ACT_ is seen, it is implicitly an activity.
If more than one $sequence has the same activity, then the weight specifies how likely this sequence is to be picked when that activity is called. The odds of any particular $sequence playing is simply its weight over the sum of all other weights.
For example, if a $sequence named swing_a has a weight of 2, and another $sequence named swing_b has a weight of 1, then there is a 2/3 chance for swing_a to play instead of swing_b.
Note.pngNote:If there is only one sequence tied to the activity, then its weight is irrelevant.
autoplay
Makes the sequence play at all times, on top of any other animations, no matter what the model is doing. Good for blended breathing animations and other automated motion. If a model has multiple autoplay $sequences, they’re layered in the order that they appear in the QC.
Warning.pngWarning:Don't use this for an animation that might be played normally, or you'll end up with it playing twice and the motion doubling up.
addlayer <string|other $sequence name>
Play another sequence on top of this one. The animations begin and end together, so discrepancies in their total run time (framerate * number of frames) will proportionately affect the added layer's framerate, if applicable. The other $sequence doesn't have to be above the current one.
This is generally used to add either delta-ed layers such as aim matrices or specially weighted layers that only affect specific bones.
The other $sequence can be declared ahead of time if it will be imported at runtime.
blendlayer <string|other $sequence name> <int|startframe> <int|peakframe> <int|tailframe> <int|endframe> [options...]
Similar to addlayer, but the new sequence only plays over specified frames, and it accepts a number of options.
The animation starts at 0% intensity on startframe, reaches 100% intensity on peakframe, starts to fade away on tailframe, and fully fades out on endframe.
Options:
spline
Instead of fading the layer linearly, fade it with a spline curve.
xfade
The layer will only fade in and not back out.
poseparameter <string|name>
Allows a pose parameter to control the fading of the layer instead of the parent $sequence's frame. When this option is present, the frame range is instead used to determine how the pose parameter's value should make the layer fade in/out.
Example: blendlayer aimmatrix -1 0 0 1 poseparameter move_x
param value: -2.000 -1.500 -1.000 -00.80 -00.60 -00.40 -00.200 000.00 00.200 00.400 00.600 00.800 1.0000 1.5000 2.0000
layer weight: 0.000% 0.000% 0.000% 20.00% 40.00% 60.00% 80.00% 100.0% 80.00% 60.00% 40.00% 20.00% 0.000% 0.000% 0.000%
These values will change when making use of the spline option, but will still start and end at the same time.
noblend
Causes the layer to stop fading in/out entirely and always be at 100% intensity while active. This also makes the layer ignore sequence transitions.
Note.pngNote:If a constant intensity is needed but ignoring sequence transitions isn't desirable, the peak and tail frames should be set to the start and end frames respectively instead. That will make the command equivalent to addlayer, but with a specific frame range.
local
Marks the layer as a local context sequence. This blends the layer with the main sequence before the main sequence's keyframes are actually applied to the bones. This is mainly useful for sequence transitions, which otherwise fade layers separately from the main sequence.
Warning.pngWarning:Unless the blended sequence has the realtime option, the blended sequence's framerate will be adjusted relative to the parent sequence so that it starts on startframe and ends on endframe. For example, if both the parent and blended sequences play at 30 frames per second and last for 30 frames, but the blended sequence only plays during frames 5 through 20 (a total of 15 frames, only half of its original length), then the blended sequence will play at 60 frames per second (twice its original framerate!) so that it can start on frame 5 and end on frame 20.
worldspace
When used as a layer, calculates the bone positions in worldspace instead of relative to the parent animation.
Note.pngNote:When weightlist is used, the weight of the root bone must not be 0.
Todo: Does it actually do anything?
worldspaceblend
Todo: Documentation
snap
Remove all blending when transitioning to this animation. This is useful for reaction animations that are the result of sudden and violent changes in the model's state, such as a creature flinching or a weapon firing.
Note.pngNote:This may look jarring and buggy on animations that repeat quickly. Such as in firing animations of rifles. As it would reset to the first frame where the gun is not yet affected by recoil without any fade. Therefore a fadein 0.05 might be a better alternative.
realtime
Normally, when a sequence is asked to play, it will start at frame 0, and can be subjected to FPS changes by any parent sequence that's adding it via blendlayer. This option changes this so that the animation is instead synchronized with the map clock. Useful for adding layers that shouldn't play at the same rate as their parent $sequence, such as breathing.
Warning.pngWarning:All models playing this animation will be synchronized to the map clock! You may want to use this sparingly, ideally on models that are only seen once in the game, such as viewmodels.
fadein <float|seconds>
Override how long this animation spends fading in. Default is 0.2.
Note.pngNote:fadein 0 achieves the same effect as snap, but HLMV HLMV will not recognize it as a snap when automatic blending is enabled, making snap necessary.
fadeout <float|seconds>
Override how long this animation spends fading out. Default is 0.2.
Tip.pngTip:You can calculate the exact frame at which the fadeout should begin by dividing that frame number by your FPS, and then subtracting that number from the result of dividing the whole framecount by the FPS.
Example: animation has a total of 200 frames, fps is 120, desired "fadeout" frame is 150 which means the calculation is: 150/120 is 1.25, then 200/120 is 1.666, then 1.666-1.25 is 0.41. 0.41 is the fadeout you want to make the fade appear on frame 150.
weightlist <string|weightlist name>
Selects a weightlist to apply to this sequence.
If a default weightlist is used, this will override it with the specified weightlist for this animation.
worldrelative (in all games since Counter-Strike: Global Offensive)
Todo: Documentation
localhierarchy <string|bone name> <string|new parent name> [range <int|startframe> <int|peakframe> <int|tailframe> <int|endframe>]
Changes a bone's parent for this animation only. "" can be used to remove the parent of a bone.
This is primarily useful for ensuring that a bone blends correctly. As an example, if a weapon is normally held in the right hand, but during this animation it's held in the left hand, it will blend as if it were being held by the right hand. This option can then be used to make it blend relative to the left hand instead, which will remove the jittering caused by blending.
range is optional, and requires four frame numbers that specify how the hierarchy should be blended over the specified frames.
Note.pngNote:This does not affect animations during transitions, making snap necessary.
compress <int|frameskip>
Saves only every frameskip frame of the input animation, starting at frame 0. A value of 1 or below does nothing.
posecycle <string|pose parameter>
Makes the specified pose parameter control the animation frame instead of the specific animation that should play in a blend sequence.
You can use it to more easily create a detailed (but entirely linear) blend sequence. Not often used in the SDK, but is faster to set up & has no limit on the number of blended $animations.
The pose parameter's min & max values will determine where the animation starts & ends. Below is an example of a parameter with a range of -180 to 180, being used on an animation with 9 total frames (range 0-8):
param value: -180.0 -135.0  -90.0  -45.0    0.0   45.0   90.0  135.0  180.0
anim frame:     0      1      2      3      4      5      6      7      8
Warning.pngWarning:If you don't forward-declare the pose parameter with $poseparameter, StudioMDL will still generate a pose parameter just like blend, but it will have an invalid range.

Advanced

In addition to all simple options:

delta
Tells Source that the $animations referenced in this sequence have all been subtracted. The $sequence will be played on top of whatever sequences are currently playing, rather than overriding them.
Warning.pngWarning:Using this with an $animation that hasn't been subtracted has bad results!
predelta
The compliment to the "presubtract" command, this tells the animation compositing system to add the current bone setup on top of a different frame of reference instead of overriding each bones’ animation based on the typical cross-fade weighting scheme.
blend <string|name> <float|min value> <float|max value>
blendwidth <int|width>
blendref <string|name>
blendcomp <string|name>
blendcenter <string|name>
calcblend <string name> <string attachment> <XR YR ZR>
See Blend sequence.
ikrule
See $ikchain.
iklock
Freezes the bone specified in an $ikchain.
See $ikchain.
activitymodifier <string|modifier> (in all games since Alien Swarm) (also in Source 2013 MultiplayerTeam Fortress 2 branch)
Todo: Documentation

Miscellaneous

node <string|name>
Tags the sequence as belonging to a point on the sequence transition graph table. This is for animations which don’t change graph state, such as looping animations. Multiple sequences can be at the same entry in the graph table, at which point they won’t need transition animations to move between each other.
Alternatively, you can have them at different points and expressly skip transitions (see $skiptransition). Sequences with no declaration are assumed at the root node and the transition graph assumes any sequence can move from the root node or to the root node without a intermediate transition.
transition <string|from> <string|to>
This specifies that the animation enters from one point on the node graph and exits at another point. This is used to play transitional sequences such as walk_to_stand, run_to_crouch, etc.
rtransition <string|name1> <string|name2>
Same as transition, but flags the sequence as able to be run in reverse order. This was used for the Tentacle in Half-Life Half-Life; except for special cases, using this isn't recommended.[Why?]
exitphase <string|phase>
When transitioning between looping animations, such as "stand_to_run", this tells the movement system where to start the next sequence, assuming it’s looping. It’s also assumed that you’ve made all the sequences that share the next node to be phase matched (see startloop).
Warning.pngWarning:Does nothing, not implemented by the game
$skiptransition <string|name1> <string|name2> <string|name3> ...]
This adds a rule to the transition graph to allow direct movement between all the named nodes. This is useful for transitions between unique named nodes that that may not require any specific intermediate animation. This is how to avoid the transition graph from forcing "walk" to "run" to instead be a "walk" to "stand" to "run" transition.
keyvalues { <stuff> }
Add a keyvalue block (see $keyvalues) to a specific sequence. This is used for setting up gestures for Faceposer.

Events

A $sequence can have certain Animation Events occur at different times during the animation, like so:

$sequence tentacle_grab "tentacle_grab" {
  fps 15
  { event 1000 1 }
  { event 1004 4 "*scientist/scream02.wav" }
  { event 1003 18 "smash" }
  { event 1004 65 "*scientist/c1a4_sci_tent.wav" }
}

The format for each event is this:

{ event <event name or ID> <frame of animation> <optional argument> }

Each sequence can have up to 1024 animation events with default studiomdl.exe

The optional argument can be up to 64 bytes/characters long. Event name can be up to 128 bytes/characters long.