Contents

AnimationGraphResource

A compiled animation graph that drives skeletal animation on an entity by blending and transitioning between animation clips at runtime.

Declaration

class AnimationGraphResource

Overview

Compile an animation graph definition once into an AnimationGraphResource, then attach it to one or more entities through AnimationGraphComponent. The same resource can drive many entities — each AnimationGraphComponent keeps its own per-instance evaluation state, so animation timing, state-machine progress, and parameter values stay independent across characters that share a graph.

Compile and attach a graph

let resource = try AnimationGraphResource(
    definition: graphDefinition,
    nodeResourceMapping: clips,
    skeletonResource: skeleton
)
entity.components.set(AnimationGraphComponent(graph: resource))

Drive the graph with parameters

A graph exposes a set of named, typed parameters that control its behavior at runtime, such as a movement speed or a trigger that initiates a transition. List the parameters declared by the graph through parameterNames. Set values through the owning entity’s parameter binding rather than through the resource itself:

entity.parameters["MoveSpeed"] = BindableValue(Float(1.0))

When the graph evaluates next, it picks up the values bound on the entity whose names and types match the graph’s declared parameters.

Validate before compiling

To check a graph definition for errors without producing a resource — for example, in editor tooling — call validate(definition:nodeResourceMapping:skeletonResource:), which returns compiler diagnostics rather than throwing.

Topics

Creating an animation graph

Accessing parameters

See Also

Animation graphs