Animation Graph API Reference#
This page lists the Python API for the Animation Graph extension. You use it to query and control characters at runtime (get/set variables, play animations, read transforms). All commands live in the omni.anim.graph.core module. Many operations are also available as nodes in the Action Graph node catalog.
get_characters#
Returns a list of active character instances. Must be called in Play mode.
Example
import omni.anim.graph.core as ag chars = ag.get_characters()
get_character_count#
Returns the number of active character instances. Must be called in Play mode.
Example
import omni.anim.graph.core as ag char_count = ag.get_character_count()
get_character#
Returns the active character instance for the specified USD Path string. Must be called in Play mode.
Arguments
arg0 (str): The USD path to the SkelRoot with an Animation Graph applied.Example
import omni.anim.graph.core as ag ag.get_character("/World/MyCharacter")
character.set_variable#
Sets a variable in a character’s applied Animation Graph. The variable can be a value or array. Must be called in Play mode.
Arguments
arg0 (str): The variable’s node name. arg1 (value): The value to be applied that matches the variable type.Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") char.set_variable("MyBoolean", True)
character.get_variable#
Returns a variable in a character’s applied Animation Graph. Returns a list. For a single-value variable, the list has one element.
Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") char.get_variable("MyBoolean")
character.is_node_active#
Returns a boolean indicating whether the given Animation Graph node is active. Must be called in Play mode.
Arguments
arg0 (str): The node name as a relative path from the Animation Graph root.Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") char.is_node_active("/MyAnimGraphNode")
character.get_world_transform#
Gets the root World Transform of a character. Must be called in Play mode.
Also available as an Action Graph node.
Arguments
arg0 (carb::Float3): The translation arg1 (carb::Float4): The rotationExample
import omni.anim.graph.core as ag import carb char = ag.get_character("/World/MyCharacter") pos = carb.Float3(0, 0, 0) rot = carb.Float4(0, 0, 0, 0) char.get_world_transform(pos, rot)
character.set_world_transform#
Sets the root World Transform on a character. Must be called in Play mode.
Also available as an Action Graph node.
Arguments
arg0 (carb::Float3): The translation arg1 (carb::Float4): The rotationExample
import omni.anim.graph.core as ag import carb char = ag.get_character("/World/MyCharacter") pos = carb.Float3(20, 0, 100) rot = carb.Float4(0, 0, 0, 0) char.set_world_transform(pos, rot)
character.get_joint_transform#
Gets the joint’s transform in world space. Must be called in Play mode.
Also available as an Action Graph node.
Arguments
arg0 (str): The joint name, not joint path. arg1 (carb::Float3): The translation arg2 (carb::Float4): The rotationExample
import omni.anim.graph.core as ag import carb char = ag.get_character("/World/MyCharacter") pos = carb.Float3(20, 0, 100) rot = carb.Float4(0, 0, 0, 0) char.get_joint_transform("Pelvis", pos, rot)
character.update#
Manually update/tick a character. Must be called in Play mode.
Arguments
arg0 (float): The delta time in seconds.Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") char.update(1.0)
character.get_joint_count#
Returns the number of joints. Must be called in Play mode.
Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") n = char.get_joint_count()
character.get_joint_local_transforms#
Gets the joint transforms in local space. Must be called in Play mode.
Two overloads: pass in
ag.vector_float3()andag.vector_float4()to fill in-place, or call with no arguments to get(positions, rotations)as returned lists.Arguments (in-place overload)
arg0 (vector_float3): List of translations (filled in-place). arg1 (vector_float4): List of rotations (filled in-place).Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") pos, rot = char.get_joint_local_transforms()
character.get_blend_shape_count#
Returns the number of blend shapes. Must be called in Play mode.
Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") n = char.get_blend_shape_count()
character.get_blend_shape_weights#
Gets all blend shape weights. Must be called in Play mode.
Two overloads: pass
ag.vector_float()to fill in-place, or call with no arguments to get a list of floats.Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") weights = char.get_blend_shape_weights()
character.get_blend_shape_weight#
Gets the weight of a single blend shape by name. Must be called in Play mode.
Arguments
arg0 (str): The name of the blend shape.Example
import omni.anim.graph.core as ag char = ag.get_character("/World/MyCharacter") w = char.get_blend_shape_weight("Key_1")
load_animation#
Loads an animation from the specified USD path and returns an Animation (direct-mode) object. Use with get_character_animator and CharacterAnimator.play_animation to play it.
Arguments
arg0 (str): The USD path of the animation to load.Keyword arguments
blend_in (float): Blend-in time in seconds (default 0.0). blend_out (float): Blend-out time in seconds (default 0.0). opacity (float): Opacity in [0.0, 1.0] (default 1.0). layer (float): Blend order; lower values are blended first (default 0.0). looping (bool): Whether the animation loops (default False). paused (bool): Whether the animation starts paused (default False).Example
import omni.anim.graph.core as ag anim = ag.load_animation("/World/Animations/Walk", looping=True, blend_in=0.2)
get_character_animator#
Returns the active CharacterAnimator instance for the given SkelRoot USD path, or None. Must be called in Play mode. Use this to play and control direct-mode animations.
Arguments
arg0 (str): The USD path to the SkelRoot with an Animation Graph applied.Example
import omni.anim.graph.core as ag animator = ag.get_character_animator("/World/MyCharacter") if animator: anim = ag.load_animation("/World/Animations/Walk", looping=True) anim_id = animator.play_animation(anim)
CharacterAnimator#
Obtained via
get_character_animator(path). Controls direct-mode playback for a character. All methods require Play mode unless noted.Playback
play_animation(animation) — Adds a direct-mode animation; returns unique animation ID.
stop_animation(animation_id) — Blends out then removes the animation.
pause_animation(animation_id) — Pauses the animation.
delete_animation(animation_id) — Removes the animation immediately (no blend-out).
seek_animation(animation_id, time_seconds) — Sets current time (seconds).
Query
is_animation_playing(animation_id) — True if the animation is active.
is_animation_looping(animation_id) — True if looping.
is_animation_paused(animation_id) — True if paused.
animation_duration(animation_id) — Duration in seconds (or 0).
current_animation_time(animation_id) — Current time in seconds (or 0).
Layer and blend
animation_layer(animation_id) / set_animation_layer(animation_id, layer)
animation_opacity(animation_id) / set_animation_opacity(animation_id, opacity)
animation_blend_in(animation_id) / set_animation_blend_in(animation_id, seconds)
animation_blend_out(animation_id) / set_animation_blend_out(animation_id, seconds)
Helper types (vector_float, vector_float3, vector_float4)#
Use these when calling overloads that fill lists in-place (for example, get_joint_local_transforms, get_blend_shape_weights):
ag.vector_float(),ag.vector_float3(),ag.vector_float4().