---
title: AnimationStreamBlendingExtensions
product: Unity Editor
version: '7000.0'
latest_version: '7000.0'
status: This page documents version 7000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:13:12.048Z
locale: en-us
---

# AnimationStreamBlendingExtensions

> Extension methods that blend, add, weight, invert, and subtract animation streams.

## Definition

* **Type:** Class
* **Namespace:** [Unity.Animations](/engine/7000.0/script-reference/unity/animations.md)
* **Assembly:** [UnityEngine.AnimationCoreModule](/engine/7000.0/script-reference/modules/unityengine-animationcoremodule.md)

```csharp
public static class AnimationStreamBlendingExtensions
```

## Remarks

These methods let you call the stream operations on the stream that receives the result, for example `stream.Blend(input, weight)`. Each method writes its result into the stream that it's called on. All the streams that you pass to a method must use the same rig. Overloads that take an [AnimationStreamMask](/engine/7000.0/script-reference/unity/animations/animationstreammask.md) scale the weight of each channel by the mask.

The following example uses the `Unity.Animations` and `Unity.Collections` namespaces. It computes the weights of walk, jog, and run streams for a speed, then blends the streams into one output stream.

Additional Resources: [BlendSpaceUtility](/engine/7000.0/script-reference/unity/animations/blendspaceutility.md), [AnimationStream](/engine/7000.0/script-reference/unity/animations/animationstream.md)

## Examples

```csharp
// This example blends walk, jog, and run streams according to a movement speed.
// The walk, jog, and run animations are placed at speeds 1, 3, and 6 in the blend space.
public static void BlendLocomotion(
    in AnimationStream walk,
    in AnimationStream jog,
    in AnimationStream run,
    float speed,
    ref AnimationStream output)
{
    // The movement speed that each stream represents, in the order walk, jog, and run.
    using NativeArray<float> animationSpeeds =
        new NativeArray<float>(new float[] { 1f, 3f, 6f }, Allocator.Temp);
    NativeArray<float> weights = new NativeArray<float>(3, Allocator.Temp);

    // Compute one weight per stream. At a speed of 2, walk and jog each get a weight of 0.5.
    // Speeds outside the range from 1 to 6 give all the weight to the nearest stream, because wrapping is off.
    // The two 0f arguments are the wrap limits, which the call ignores when wrapping is off.
    BlendSpaceUtility.ComputeBlendSpace1DWeights(
        speed, animationSpeeds, false, 0f, 0f, weights);

    // Start from the walk stream, then blend in each other stream with a weight
    // relative to the total weight accumulated so far.
    output.CopyFrom(walk);
    float accumulatedWeight = weights[0];

    if (weights[1] > 0f)
    {
        accumulatedWeight += weights[1];
        output.Blend(jog, weights[1] / accumulatedWeight);
    }

    if (weights[2] > 0f)
    {
        accumulatedWeight += weights[2];
        output.Blend(run, weights[2] / accumulatedWeight);
    }

    // Dispose the weights explicitly, because a using declaration can't be passed by reference.
    weights.Dispose();
}
```

## Static Methods

| Method                                                                                                               | Description                                                                                                                        |
| -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| [Add](/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions/add.md)                     | Adds stream values to the current stream.                                                                                          |
| [Blend](/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions/blend.md)                 | Blends an input stream with the current stream using a blending value.                                                             |
| [BlendAdditive](/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions/blendadditive.md) | Blend stream with an additive stream using a blend weight value.                                                                   |
| [Delta](/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions/delta.md)                 | Computes the difference between input and a stream to subtract (delta = subtract^-1 \* input) and stores the result in the stream. |
| [Inverse](/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions/inverse.md)             | Inverts the stream.                                                                                                                |
| [Weight](/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions/weight.md)               | Weights the stream using a stream weight mask.                                                                                     |
