Blend sequence: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(→‎Example: correction, example of addlayer)
Line 26: Line 26:


$sequence walk {
$sequence walk {
walk_SW  walk_S  walk_SE
walk_W    walk_C  walk_E
walk_NW  walk_N  walk_NE // line breaks are for readability only
walk_NW  walk_N  walk_NE // line breaks are for readability only
walk_W    walk_C  walk_E
walk_SW  walk_S  walk_SE


blendwidth 3
blendwidth 3
  blend move_x -1 1
  blend move_x -1 1
  blend move_y -1 1
  blend move_y -1 1
addlayer look // blends look/aim direction on top of walk direction
}
}
</source>
</source>

Revision as of 06:41, 7 July 2011

Stub

This article or section is a stub. You can help by expanding it.

A blend sequence altering the yaw of an NPC's aim. A second blend sequence will be needed to control pitch.
HLMV's 'Sequence' tab can control blends. This character is running backwards and aiming slightly upwards.

A Blend sequence is a $sequence that can move smoothly between $animations based on one or two sliding 'blend scale' values. This allows the animation's state to be easily controlled by code.

Walking and aiming direction are almost always determined by blend sequences.

Creating blend sequences

The ideal number of animations in a blend sequence depends on how precise the motion needs to be, and on how much variation there is to be along the blend scale. Valve use nine for their walking blends (see the example below). With blends that produce a still pose rather than an animation you can get away with one for each extreme, but may find it easier to work with a third, central animation for the zero position.

Once you have your animations, simply list them within the sequence's keyvalue block in the desired order. They will be evenly distributed along the blend scale.

blend <string name> <float min> <float max>
Defines a blend controller. The first controller moves up/down through the blend, the second (if present) left/right.
blendwidth <int width>
How many columns of animations the blend contains. The number of rows is determined automatically.

Example

// Define all nine walk_* $animations above this command (use walkframe!)

$sequence walk {
	walk_SW   walk_S   walk_SE
	walk_W    walk_C   walk_E
	walk_NW   walk_N   walk_NE // line breaks are for readability only

	blendwidth 3
 	blend move_x -1 1
 	blend move_y -1 1

	addlayer look // blends look/aim direction on top of walk direction
}

Animating for blend sequences

To do...

Tip.pngTip:The $animations used in blends are usually still poses, as movement is generated by other animations that play on top. If they aren't, e.g. for walking blends, it is important that each $animation used is the same length and plays at the same framerate!

See also