<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: 15.0.0 -",
    "macOS: 12.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/BlendTreeAnimation",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation18BlendTreeAnimationV"
  },
  "title" : "BlendTreeAnimation"
}
-->

# BlendTreeAnimation

A collection of animations on the same property that the framework blends to
a single animation.

```
struct BlendTreeAnimation<Value> where Value : AnimatableData
```

## Overview

This structure provides a way to form a single animation by mixing several
other animations together. You define a source node for each animation, and
a weight, which determines how much each individual animation takes effect
in the resulting animation.

To create the blended animation, you define a *blend tree* that sprouts from
[`root`](/documentation/RealityKit/BlendTreeAnimation/root), which consists of one or more blend-tree nodes
([`BlendTreeNode`](/documentation/RealityKit/BlendTreeNode)). Each node may be one of the following conforming types:

- [`BlendTreeBlendNode`](/documentation/RealityKit/BlendTreeBlendNode), which branches the tree for every element in
  [`sources`](/documentation/RealityKit/BlendTreeBlendNode/sources)
- [`BlendTreeSourceNode`](/documentation/RealityKit/BlendTreeSourceNode), which defines one of the animations to blend
  via its [`source`](/documentation/RealityKit/BlendTreeSourceNode/source) property

Because source nodes reference no other nodes, they represent leaf nodes in
the tree.

### Blending two skeletal movements to a single movement

The following animation plays a sampling of the animations named
`anim1` and `anim2`. To fine-tune the interplay between the two animations,
the code sets a blend weight for each animation. The weight of `0.25` for
`anim1` determines that the first animation’s behavior is 25% prominent in
the final result. The `anim2` weight is `0.75`, as the cumulative blend
weight across all animations in the tree needs to equal `1`. This determines
that the second animation influences 75% of the visual behavior of the
blended animation.

```swift
let anim1 = FromToByAnimation<JointTransforms>(
    name: "anim1",
    from: JointTransforms([Transform(scale: SIMD3<Float>(1, 2, 3),
    rotation: simd_quatf(ix: 5, iy: 6, iz: 7, r: 8),
    translation: SIMD3<Float>(10, 20, 30))]),
    to: JointTransforms([Transform(scale: SIMD3<Float>(11, 21, 31),
    rotation: simd_quatf(ix: 50, iy: 60, iz: 70, r: 80),
    translation: SIMD3<Float>(100, 200, 300))]),
    duration: 1.0)

let anim2 = FromToByAnimation<JointTransforms>(
    name: "anim2",
    from: JointTransforms([Transform(scale: SIMD3<Float>(10, 20, 30),
    rotation: simd_quatf(ix: 4, iy: 5, iz: 5, r: 7),
    translation: SIMD3<Float>(100, 200, 300))]),
    to: JointTransforms([Transform(scale: SIMD3<Float>(110, 210, 310),
    rotation: simd_quatf(ix: 500, iy: 60, iz: 70, r: 80),
    translation: SIMD3<Float>(1000, 2000, 3000))]),
    duration: 10.0)

let blendTree = BlendTreeAnimation<JointTransforms>(
    blend(
        BlendTreeSourceNode(
            source: anim1,
            name: "anim1",
            weight: .value(0.25)),
        BlendTreeSourceNode(
            source: anim2,
            name: "anim2",
            weight: .value(0.75)),
        name: "blend"),
    name: "blendTree",
    bindTarget: .parameter("bar")
)
```

> Tip: To modify the weights for each frame, create a source node with a
> dynamic ``doc://com.apple.RealityKit/documentation/RealityKit/BlendWeight``, such as with the
> ``doc://com.apple.RealityKit/documentation/RealityKit/BlendWeight/bindTarget(_:defaultWeight:)`` or
> ``doc://com.apple.RealityKit/documentation/RealityKit/BlendWeight/parameter(_:defaultWeight:)`` enumeration cases.

## Topics

### Creating an animation

[`init(_:name:isAdditive:bindTarget:blendLayer:repeatMode:fillMode:trimStart:trimEnd:trimDuration:offset:delay:speed:)`](/documentation/RealityKit/BlendTreeAnimation/init(_:name:isAdditive:bindTarget:blendLayer:repeatMode:fillMode:trimStart:trimEnd:trimDuration:offset:delay:speed:))

Creates a unique animation from a combination of other animations in the
form of a tree.

### Configuring the animation

[`root`](/documentation/RealityKit/BlendTreeAnimation/root)

The first node in a tree of animations.

[`name`](/documentation/RealityKit/BlendTreeAnimation/name)

A textual name for the animation.

[`bindTarget`](/documentation/RealityKit/BlendTreeAnimation/bindTarget)

A textual name that identifies the particular property that animates.

[`blendLayer`](/documentation/RealityKit/BlendTreeAnimation/blendLayer)

The order in which the framework composites the animation.

[`isAdditive`](/documentation/RealityKit/BlendTreeAnimation/isAdditive)

A Boolean value that indicates whether the animation builds on the
current state of the target entity or resets the state before running.

### Timing the animation

[`speed`](/documentation/RealityKit/BlendTreeAnimation/speed)

A factor that increases or decreases the animation’s rate of playback.

[`delay`](/documentation/RealityKit/BlendTreeAnimation/delay)

An amount of time that lapses before the animation plays.

[`duration`](/documentation/RealityKit/BlendTreeAnimation/duration)

The total playback time of the animation.

[`offset`](/documentation/RealityKit/BlendTreeAnimation/offset)

The time, in seconds, at which the animation begins within the duration.

[`trimDuration`](/documentation/RealityKit/BlendTreeAnimation/trimDuration)

An optional duration that overrides the calculated duration.

[`trimStart`](/documentation/RealityKit/BlendTreeAnimation/trimStart)

The optional time, in seconds, at which the source animation plays.

[`trimEnd`](/documentation/RealityKit/BlendTreeAnimation/trimEnd)

The optional time, in seconds, at which the source animation stops.

### Repeating animation playback

[`repeatMode`](/documentation/RealityKit/BlendTreeAnimation/repeatMode)

An option that determines how the animation repeats.

[`fillMode`](/documentation/RealityKit/BlendTreeAnimation/fillMode)

An option that determines which data displays outside of the normal
duration.



---

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)