---
title: BlendSpaceUtility
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/blendspaceutility
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/blendspaceutility.md
last_updated: 2026-11-30
generated_at: 2026-11-30T20:46:55.041Z
locale: en-us
---

# BlendSpaceUtility

> Provides methods that compute the weights of the animations in one-dimensional and two-dimensional blend spaces.

## 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 BlendSpaceUtility
```

## Remarks

A blend space mixes several animations according to an input value. The class has one method for each kind of blend space:

* [BlendSpaceUtility.ComputeBlendSpace1DWeights](/engine/7000.0/script-reference/unity/animations/blendspaceutility/computeblendspace1dweights.md) for animations that sit on a line.

* [BlendSpaceUtility.ComputeBlendSpace2DSimpleDirectionalWeights](/engine/7000.0/script-reference/unity/animations/blendspaceutility/computeblendspace2dsimpledirectionalweights.md) for animations that sit in different directions around an optional center point.

* [BlendSpaceUtility.ComputeBlendSpace2DFreeformWeights](/engine/7000.0/script-reference/unity/animations/blendspaceutility/computeblendspace2dfreeformweights.md) for animations at arbitrary positions in a plane.

In a one-dimensional blend space, each animation is tied to a value on a line, and `ComputeBlendSpace1DWeights` converts the input value into one weight per animation. When the input matches a value exactly, that animation gets a weight of 1. When the input falls between two values, those two animations share the weight in proportion to the distance, and every other animation gets a weight of 0. When the input is outside the range of the values and wrapping is off, the first or last animation gets a weight of 1.

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: [AnimationStreamBlendingExtensions](/engine/7000.0/script-reference/unity/animations/animationstreamblendingextensions.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                                                                                  |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- |
| [ComputeBlendSpace1DWeights](/engine/7000.0/script-reference/unity/animations/blendspaceutility/computeblendspace1dweights.md)                                   | Compute 1D blend space weights given an input, wrap information and animation stream values. |
| [ComputeBlendSpace2DFreeformWeights](/engine/7000.0/script-reference/unity/animations/blendspaceutility/computeblendspace2dfreeformweights.md)                   | Computes the weights of a 2D freeform blend space.                                           |
| [ComputeBlendSpace2DSimpleDirectionalWeights](/engine/7000.0/script-reference/unity/animations/blendspaceutility/computeblendspace2dsimpledirectionalweights.md) | Computes the weights of a 2D simple directional blend space.                                 |
