Skip to content

$animation

Drive animation trees and attributes on an entity.

26 natives. Read-only natives only look things up; the rest change something. Parameter types use the language's names (Types).

anim_tree

$animation.anim_tree(entity: Entity, tree: Reference, transitions: list, time: int)

Declare an immediate mode anim tree instance and update it. Only one instance of the same anim_tree asset can be declared per component.

ParameterTypeMeaning
entityEntityThe entity context.
treeReferenceThe tree.
transitionslistThe hash values of the transition names whose conditions are met.
timeintThe time of the tree in milliseconds. Determines state machine times. See also animation.set_pos_time.

attribute

$animation.attribute(entity: Entity, name_hash: int, value: var)

Declare a named animation attribute for the specified entity.

ParameterTypeMeaning
entityEntityThe entity context.
name_hashintThe hash value of the attribute name.
valuevarThe attribute value.

blend_list_of_poses_linear

$animation.blend_list_of_poses_linear(poses: list, weights: list) -> int

Linearly blend multiple poses into a new pose.

ParameterTypeMeaning
poseslistA list of pose handles.
weightslistA list of weights for poses. Don't specify to blend each pose equally.

Returns int: A handle to the pose that will remain valid for this frame only.

blend_poses_additive

$animation.blend_poses_additive(pose: int, additive_pose: int, additive_base_pose: int, blend_weight: float) -> int

Blend two poses into a new pose using an additive blend.

ParameterTypeMeaning
poseintA pose handle.
additive_poseintThe additive pose handle.
additive_base_poseintThe handle of the pose additive_pose is sampled relative to, or k_vanim_null_pose_handle to sample additive_pose relative to its default additive base animation (specified on a .animation asset).
blend_weightfloatThe additive blend weight.

Returns int: A handle to the pose that will remain valid for this frame only.

blend_poses_layer

$animation.blend_poses_layer(pose1: int, pose2: int) -> int

Blend two poses into a new pose using a layer blend. Pose 2 shows through at the bones not fully contributed to by pose 1.

ParameterTypeMeaning
pose1intA pose handle.
pose2intAnother pose handle.

Returns int: A handle to the pose that will remain valid for this frame only.

blend_poses_linear

$animation.blend_poses_linear(pose1: int, pose2: int, blend_weight: float) -> int

Blend two poses into a new pose using a linear blend.

ParameterTypeMeaning
pose1intA pose handle.
pose2intAnother pose handle.
blend_weightfloatWeight of pose2, 1 - weight of pose1.

Returns int: A handle to the pose that will remain valid for this frame only.

fire_triggers

$animation.fire_triggers(entity: Entity, recipients_root_entity: Entity)

Fire animation triggers of animations playing on the specified entity.

ParameterTypeMeaning
entityEntityThe animated entity. Must be the same entity as input from animation.set_model_pose
recipients_root_entityEntityScript events can be received on components of this entity and its children.

get_bone_position

$animation.get_bone_position(bone_name: string, entity: Entity, ragdoll: Reference, ignore_warning: bool, allowed_error: float, empty_list_if_not_found: bool) -> list

Get the model-space position of a bone in the specified animation. Samples the animation if not already sampled this frame.

ParameterTypeMeaning
bone_namestringName of the bone to sample.
entityEntityThe entity to retrieve pose from, also used for combining skeletons for animation. Must be the same entity as input from animation.set_model_pose
ragdollReferenceAn optional ragdoll
ignore_warningboolWhether to ignore warning if bone doesn't exist
allowed_errorfloatAllowed world unit error when posing skeleton. Higher values allow faster processing
empty_list_if_not_foundboolWhether to return an empty list (zero elements) or a zero vector (three elements) when a bone doesn't exist, useful when code needs to detect when a bone isn't found

Returns list: List containing the bone position and rotation in model space.

get_duration

read-only
$animation.get_duration(animation: Reference) -> float

Get the duration of the specified animation in seconds.

ParameterTypeMeaning
animationReferenceThe animation.

Returns float: The animation duration in seconds.

get_last_sync_tree_time

read-only
$animation.get_last_sync_tree_time(tree: Reference, state_machine_name: string) -> int

Get the last sync transition time

ParameterTypeMeaning
treeReferenceThe tree.
state_machine_namestringThe fullname of a tree node of type state machine.

Returns int: Last synced transition time in milliseconds.

get_name

$animation.get_name(animation: Reference) -> string

Get the name of the specified animation or blendspace.

ParameterTypeMeaning
animationReferenceThe animation.

Returns string: The animation name.

get_spreadsheet_column_length

read-only
$animation.get_spreadsheet_column_length(spreadsheet: Reference, column: int) -> int

Get the length of a spreadsheet column.

ParameterTypeMeaning
spreadsheetReferenceThe spreadsheet.
columnintThe column. Zero indexed.

Returns int: The column length.

get_spreadsheet_row_length

read-only
$animation.get_spreadsheet_row_length(spreadsheet: Reference, row: int) -> int

Get the length of a spreadsheet row.

ParameterTypeMeaning
spreadsheetReferenceThe spreadsheet.
rowintThe row. Zero indexed.

Returns int: The row length.

get_spreadsheet_value

read-only
$animation.get_spreadsheet_value(spreadsheet: Reference, row: int, column: int) -> Reference

Get an animation from a spreadsheet by row and column.

ParameterTypeMeaning
spreadsheetReferenceThe spreadsheet.
rowintThe row. Zero indexed.
columnintThe column. Zero indexed.

Returns Reference: The animation.

get_time_step

$animation.get_time_step(animation: Reference) -> float

Get the time step of the specified animation in seconds.

ParameterTypeMeaning
animationReferenceThe animation.

Returns float: The animation time step in seconds.

get_tree_state

$animation.get_tree_state(tree: Reference, state_machine_name: string) -> list

Get the names of the current state of an anim tree state machine (Example: if transitioning to the node root.hit.start, [hit, start] is returned.)

ParameterTypeMeaning
treeReferenceThe tree.
state_machine_namestringThe fullname of a tree node of type state machine.

Returns list: The fullname of the current state in list format.

get_tree_transition_state

$animation.get_tree_transition_state(tree: Reference, state_machine_name: string) -> list

Get the id and start time of an anim tree state machine's transition. The transition id will be the same in all game instances.

ParameterTypeMeaning
treeReferenceThe tree.
state_machine_namestringThe fullname of a tree node of type state machine.

Returns list: The list [transition id, transition start time].

is_rollback_enabled

read-only
$animation.is_rollback_enabled() -> bool

Query if animation rollback is enabled.

Returns bool: True if animation rollback is enabled, false otherwise.

override_list_attribute

$animation.override_list_attribute(entity: Entity, spreadsheet: Reference, original_col: int, override_col: int, allow_null_override: bool)

Declare a spreadsheet of animation overrides for the specified entity. Overridden animations can be overridden if this function is called again.

ParameterTypeMeaning
entityEntityThe entity context.
spreadsheetReferenceThe spreadsheet of animation overrides.
original_colintThe spreadsheet column containing animations to be replaced. Zero indexed.
override_colintThe spreadsheet column containing replacement animations. Zero indexed.
allow_null_overrideboolWhether animations may be replaced by null.

pose

$animation.pose(ref: Reference, entity: Entity) -> int

Make a pose from either an animation or a blendspace or an anim tree. The returned pose handle is only valid for this frame and on this component.

ParameterTypeMeaning
refReferenceThe animation or blendspace or anim tree.
entityEntityThe entity context.

Returns int: A handle to the pose that will remain valid for this frame only.

set_model_pose

$animation.set_model_pose(entity: Entity, pose: int)

Set the pose that will be used for animation sampling of a model. Neither this pose nor its children may be modified after this call.

ParameterTypeMeaning
entityEntityThe entity to use as pose context
poseintA pose handle.

set_pose_blendspace_inputs

$animation.set_pose_blendspace_inputs(pose: int, inputs: list)

Apply blendspace inputs to a pose.

ParameterTypeMeaning
poseintA pose handle.
inputslistHashed names and values of blendspace inputs. Anim tree blend inputs must be in range [0, 1].

set_pose_time

$animation.set_pose_time(pose: int, time: int, elapsed_time: int)

Set the animation time of a pose.

ParameterTypeMeaning
poseintA pose handle.
timeintThe time in milliseconds. Child poses inherit this time if they have no other source of time, such as the time of an anim tree state machine transition, or time specified by another call to set_pose_time.
elapsed_timeintThe difference between time_ms this frame and last frame in milliseconds. This is used to evaluate animation triggers.

sync_tree

$animation.sync_tree(tree: Reference, state_machine_name: string, target_transition_id: int, target_transition_time: int) -> bool

Synchronize an anim tree state machine with a target transition.

ParameterTypeMeaning
treeReferenceThe tree.
state_machine_namestringThe fullname of a tree node of type state machine.
target_transition_idintThe id of the desired transition.
target_transition_timeintThe start time of the desired transition in milliseconds.

Returns bool: True if the anim tree changed during the sync, False otherwise.

unpack_blendspace

read-only
$animation.unpack_blendspace(blendspace: Reference, input_name: string, input_value: vec3) -> list

Unpack an animation blendpsace given an input value.

ParameterTypeMeaning
blendspaceReferenceThe animation blendspace to unpack
input_namestringThe blendspace input name
input_valuevec3The blendspace input value

Returns list: List of pairs containing an animation instance index and a corresponding weight.

wait

$animation.wait(component: Component)

Wait for a component which is expected to call set_model_pose.

ParameterTypeMeaning
componentComponentThe component to wait for.