Contents

AnimationGraphComponent

A component that drives skeletal animation on an entity using an animation graph.

Declaration

struct AnimationGraphComponent

Overview

AnimationGraphComponent attaches a compiled AnimationGraphResource to an entity. The component evaluates the graph each frame, computes a skeletal pose by blending and transitioning between animation clips, and applies the resulting pose to the entity’s SkeletalPosesComponent.

Multiple components in the same scene can reference the same resource, which lets a single graph drive many entities without duplicating its underlying data. Each component keeps its own per-instance evaluation state — animation timing, state-machine progress, and parameter values — so characters that share a graph stay independent.

Attach a graph to an entity

entity.components.set(AnimationGraphComponent(graph: graphResource))

Inspect the active graph state

The component exposes the graph’s runtime state for debugging and for building tools that visualize what a character is doing. activeNodes returns every node that contributed to the most recent pose. To work with a single kind of node, iterate activeStateMachineNodes or activeClipNodes instead — those collections return the narrower AnimationGraphComponent.ActiveStateMachineNode and AnimationGraphComponent.ActiveClipNode types, which expose only the fields that apply to that node kind.

for node in component.activeStateMachineNodes {
    print("\(node.name): state \(node.currentState)")
}

for node in component.activeClipNodes {
    print("\(node.name): cycle \(node.currentCycle)")
}

To observe outputs the graph emits back to the rest of the application, read activeTags. Tags are graph-level signals that the graph raises while certain states are active.

Topics

Creating a component

Accessing the graph

Accessing active nodes

Accessing active tags

See Also

Animation graphs