---
title: FreeformBlendSpace2DData
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/freeformblendspace2ddata
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/freeformblendspace2ddata.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:21:06.206Z
locale: en-us
---

# FreeformBlendSpace2DData

> The precomputed data that the freeform 2D blend space function of BlendSpaceUtility needs.

## Definition

* **Type:** Struct
* **Namespace:** [Unity.Animations](/engine/7000.0/script-reference/unity/animations.md)
* **Assembly:** [UnityEngine.AnimationCoreModule](/engine/7000.0/script-reference/modules/unityengine-animationcoremodule.md)
* **Implements:** [IDisposable](https://learn.microsoft.com/dotnet/api/system.idisposable)

```csharp
public struct FreeformBlendSpace2DData : IDisposable
```

## Remarks

The constructor precomputes the geometry of the blend space once for a set of animation positions and for one [FreeformBlendSpace2DMode](/engine/7000.0/script-reference/unity/animations/freeformblendspace2dmode.md).

Reuse the same instance for every call of [BlendSpaceUtility.ComputeBlendSpace2DFreeformWeights](/engine/7000.0/script-reference/unity/animations/blendspaceutility/computeblendspace2dfreeformweights.md), as long as the animation positions don't change. The data holds unmanaged memory. Call [FreeformBlendSpace2DData.Dispose](/engine/7000.0/script-reference/unity/animations/freeformblendspace2ddata/dispose.md) when you no longer need it.

The weight function also writes temporary data inside the instance. Don't use the same instance from several threads or jobs at the same time.

The following example uses the `Unity.Collections` and `Unity.Mathematics` namespaces. It computes the weights of several streams for a 2D input, then mixes the streams with a [Core.PoseMixer](/engine/7000.0/script-reference/unity/animations/core/posemixer.md).

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

## Examples

```csharp
// This example blends several poses placed in a 2D blend space, for example the strafe animations of a
// character, according to a 2D input such as the movement direction and speed.
// The poses buffer holds the animated data of one pose after the other, in the same order as the positions,
// each with the stream size of the rig of the output stream.
public static void BlendStrafe(
    NativeArray<AnimatedData> poses,
    NativeArray<float2> positions,
    float2 input,
    ref AnimationStream output)
{
    // Precompute the data of the blend space once, and keep it as long as the positions do not change.
    // The mode selects the algorithm that computes the weights.
    using FreeformBlendSpace2DData blendSpace =
        new FreeformBlendSpace2DData(positions, FreeformBlendSpace2DMode.Cartesian, Allocator.Temp);

    // Compute one weight per pose.
    using NativeArray<float> weights = new NativeArray<float>(positions.Length, Allocator.Temp);
    BlendSpaceUtility.ComputeBlendSpace2DFreeformWeights(input, blendSpace, weights);

    // Mix all the poses with their weights. The weights sum to 1, so the default pose has no influence.
    // A stream can't be stored in an array, so create a read-only stream on each pose when you mix it.
    ref RigDefinition rig = ref output.RigDefinition;
    int streamSize = rig.Bindings.StreamSize;
    Core.PoseMixer mixer = default;
    mixer.Begin(ref output);
    for (int i = 0; i < positions.Length; ++i)
    {
        AnimationStream pose = AnimationStream.CreateReadOnly(ref rig, poses.GetSubArray(i * streamSize, streamSize));
        mixer.Add(ref output, pose, weights[i]);
    }

    mixer.End(ref output, default);
}
```

## Constructors

| Constructor                                                                                                                                                                                                                                   | Description                                     |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------- |
| [FreeformBlendSpace2DData(Unity.Collections.NativeArray\{Unity.Mathematics.float2},Unity.Animations.FreeformBlendSpace2DMode,Unity.Collections.Allocator)](/engine/7000.0/script-reference/unity/animations/freeformblendspace2ddata/ctor.md) | Precomputes the data of a freeform blend space. |

## Properties

| Property                                                                                            | Description                                  |
| --------------------------------------------------------------------------------------------------- | -------------------------------------------- |
| [Count](/engine/7000.0/script-reference/unity/animations/freeformblendspace2ddata/count.md)         | The number of animations in the blend space. |
| [IsCreated](/engine/7000.0/script-reference/unity/animations/freeformblendspace2ddata/iscreated.md) | Whether the data holds allocated memory.     |
| [Mode](/engine/7000.0/script-reference/unity/animations/freeformblendspace2ddata/mode.md)           | The algorithm this data was precomputed for. |

## Methods

| Method                                                                                          | Description                              |
| ----------------------------------------------------------------------------------------------- | ---------------------------------------- |
| [Dispose](/engine/7000.0/script-reference/unity/animations/freeformblendspace2ddata/dispose.md) | Releases the memory that the data holds. |
