<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/AnimationGraphResource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation22AnimationGraphResourceC"
  },
  "title" : "AnimationGraphResource"
}
-->

# AnimationGraphResource

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

```
class AnimationGraphResource
```

## Overview

Compile an animation graph definition once into an [`AnimationGraphResource`](/documentation/RealityKit/AnimationGraphResource), then attach
it to one or more entities through [`AnimationGraphComponent`](/documentation/RealityKit/AnimationGraphComponent). The same resource can
drive many entities — each [`AnimationGraphComponent`](/documentation/RealityKit/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

```swift
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`](/documentation/RealityKit/AnimationGraphResource/parameterNames). Set values through the owning entity’s
parameter binding rather than through the resource itself:

```swift
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:)`](/documentation/RealityKit/AnimationGraphResource/validate(definition:nodeResourceMapping:skeletonResource:)),
which returns compiler diagnostics rather than throwing.

## Topics

### Creating an animation graph

[`convenience init(definition: Data, nodeResourceMapping: [Int : AnimationResource], skeletonResource: SkeletonResource) throws`](/documentation/RealityKit/AnimationGraphResource/init(definition:nodeResourceMapping:skeletonResource:))

Compiles an animation graph definition into a resource that can drive animation on an
entity.

[`static func validate(definition: Data, nodeResourceMapping: [Int : AnimationResource], skeletonResource: SkeletonResource) -> [String]`](/documentation/RealityKit/AnimationGraphResource/validate(definition:nodeResourceMapping:skeletonResource:))

Compiles an animation graph definition and returns any diagnostic messages the
compiler produced, without producing a resource.

### Accessing parameters

[`var parameterNames: [String]`](/documentation/RealityKit/AnimationGraphResource/parameterNames)

The names of all parameters declared by the graph definition.

## Relationships

### Conforms To

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`Sendable`](/documentation/Swift/Sendable)

[`Resource`](/documentation/RealityKit/Resource)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)