Animation selection setup
Animation Selector is a set of configuration files used to define rules for selecting and playing animations based on the current FSM-state of a unit’s.
How the Animation Selector works
When a unit transitions to a new state, the state handler queries the Animation Selector files to determine which animation should be played. The file defines:
animation sets available for the given state;
conditions for selecting a specific animation (e.g., depending on pose, weapon, view direction);
priorities and fallback animations
Each FSM definition in the resources has a corresponding Animation Selector file with the same name.
Animation Selector files are stored in the \properties\animation_selector\
folder. Files have the .set extension.
Examples:
human.set
— used for thehuman
entityanimal.set
— used for animal entities, such ashorse
Animation files are stored either in the corresponding entity’s folder or in the shared directory: \properties\animation\
and its subfolders.
Animation Selector description structure
The Animation Selector description includes the following elements:
Request name
Condition;
Animation assignment;
Animation playback speed.
Animation Request Name
The request name in the Animation Selector usually matches the name of the animated object’s state. The request name may include words that clarify the context
Examples:
stand_idle
walk
lie_holdback_in
Here's the English translation of your technical documentation text, formatted for GitBook and aligned with the Gem RTS documentation style:
Animation Specification Methods
1. Specifying a Direct Animation
To play a specific animation, use the anm
block:
Syntax:
{anm "animation_name"}
The animation name is written in double quotes.
The string
" "
(empty string) means no animation will be played — the current animation will remain active.
2. Random Animation Selection
The random_select
block allows specifying a list of alternative animations with weighted probability:
Syntax:
{random_select {weight n1 "animation_1"} {weight n2 "animation_2"} ... }
weight
sets the relative probabilityn
, from0.01
to100
.Animation names are written in double quotes.
3. Counter-based Animation Selection
Looped switching of animation sets based on a numerical counter is done using the switch_by_counter
block. This mechanism is useful for creating varied animations such as poses, walk cycles, reactions, emotions, and other repeating states.
Syntax:
{switch_by_counter <counter_name> {common [...]} {pick <N> [...]} {pick <N> [...]} ... }
<counter_name>
The name of the counter that determines the current switch state.
common
(Optional) Base animation set copied into each pick
block before it is applied.
pick <N>
A pick option. The value N
means this pick is used for N
consecutive counter values.
How it works:
The counter starts at
0
, selecting the firstpick
block.Each time the counter is triggered, its value increases by
1
, moving to the next pick.The counter wraps around: once it reaches the total sum of all
N
values inpick
, it resets to0
.Inside each
pick
, the contents ofcommon
(if defined) are copied and then overridden or extended by the currentpick
. This means eachpick
can:inherit from
common
;Override specific fields;
Extend the base animation set with additional keys.
If common
is not defined, all animation sets are taken directly from each pick
.
Animation playback speed
Animation playback speed is defined by a number following the animation name:
Example:
{anm "animation_name" 0.75}
If speed is not defined, the default is
1.0
.Negative values (e.g.,
-1
) play the animation in reverse.
Conditions in the Animation Selector
The Animation Selector system supports conditions that adapt animation selection to the actor's current state or environment.
Conditions are defined within if
blocks and can be:
simple;
compound;
nested.
Any valid condition for the actor type can be used.
If the condition evaluates as true, only the animations within that block are considered. If no condition is met and no fallback animation is defined, the current animation remains unchanged.
Syntax of a Condition in the Animation Selector:
{if [condition] [...] ; anm or random_select }
Multiple conditions can be combined (implicitly using and
).
Syntax of Compound Conditions
{if cond1 cond2 cond3 [...] }
In the idle-selector, logical operators like and
, not
and or
are also supported in compound conditions.
Conditions can be nested.
Syntax of Nested Conditions
{if cond1 {if cond2 {anm "animation_1"} } {anm "animation_2"} }
Last updated