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

# quaternion4

> Four quaternions stored as a structure of arrays, to process four rotations at the same time.

## 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:** [IEquatable\<quaternion4>](https://learn.microsoft.com/dotnet/api/system.iequatable-1), [IFormattable](https://learn.microsoft.com/dotnet/api/system.iformattable)

```csharp
public struct quaternion4 : IEquatable<quaternion4>, IFormattable
```

## Remarks

Use a quaternion4 to apply the same operation to four rotations at once, for better performance than processing the rotations one at a time. For example, you can blend the rotation channels of a rig four at a time. The rotation channels of an [AnimationStream](/engine/7000.0/script-reference/unity/animations/animationstream.md) are stored as quaternion4 chunks.

Each of the fields [quaternion4.x](/engine/7000.0/script-reference/unity/animations/quaternion4/x.md), [quaternion4.y](/engine/7000.0/script-reference/unity/animations/quaternion4/y.md), [quaternion4.z](/engine/7000.0/script-reference/unity/animations/quaternion4/z.md), and [quaternion4.w](/engine/7000.0/script-reference/unity/animations/quaternion4/w.md) is a `float4` that holds one component of all four quaternions. Lane 0 of every field belongs to the first quaternion, lane 1 to the second quaternion, and so on. This layout is called structure of arrays and lets the central processing unit (CPU) process the four lanes together with single instruction, multiple data (SIMD) instructions.

The operators of this struct and the methods in [Quaternion4Extensions](/engine/7000.0/script-reference/unity/animations/quaternion4extensions.md) apply the operation to each lane separately.

The following example uses the `Unity.Animations` and `Unity.Mathematics` namespaces. It combines four parent rotations with four local rotations in one operation, then reads each result back.

Additional Resources: [Quaternion4Extensions](/engine/7000.0/script-reference/unity/animations/quaternion4extensions.md)

## Examples

```csharp
// This example combines four parent rotations with four local rotations in one operation.
// Lane i of the result is math.mul(parentRotations[i], localRotations[i]).
public static quaternion[] CombineFourRotations(quaternion[] parentRotations, quaternion[] localRotations)
{
    // Pack four quaternions into one quaternion4. Each field of a quaternion4 is a float4 that holds one
    // component of all four quaternions. For example, parents.x holds the x components of the four parent
    // rotations. The y, z, and w fields hold the other components in the same way.
    quaternion4 parents = new quaternion4(
        parentRotations[0], parentRotations[1], parentRotations[2], parentRotations[3]);
    quaternion4 locals = new quaternion4(
        localRotations[0], localRotations[1], localRotations[2], localRotations[3]);

    // Multiply the four pairs at once.
    quaternion4 combined = parents.Mul(locals);

    // Read each lane back as a regular quaternion.
    quaternion[] results = new quaternion[4];
    for (int lane = 0; lane < 4; ++lane)
    {
        results[lane] = math.quaternion(
            combined.x[lane], combined.y[lane], combined.z[lane], combined.w[lane]);
    }

    return results;
}
```

## Fields

| Value                                                                  | Description                                                 |
| ---------------------------------------------------------------------- | ----------------------------------------------------------- |
| [w](/engine/7000.0/script-reference/unity/animations/quaternion4/w.md) | The w components of the four quaternions, one in each lane. |
| [x](/engine/7000.0/script-reference/unity/animations/quaternion4/x.md) | The x components of the four quaternions, one in each lane. |
| [y](/engine/7000.0/script-reference/unity/animations/quaternion4/y.md) | The y components of the four quaternions, one in each lane. |
| [z](/engine/7000.0/script-reference/unity/animations/quaternion4/z.md) | The z components of the four quaternions, one in each lane. |

## Static Fields

| Value                                                                                | Description                                                         |
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------- |
| [identity](/engine/7000.0/script-reference/unity/animations/quaternion4/identity.md) | A quaternion4 where all four quaternions are the identity rotation. |

## Constructors

| Constructor                                                                                                                                                                                                                                                         | Description                                                                               |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| [quaternion4(Unity.Mathematics.float4,Unity.Mathematics.float4,Unity.Mathematics.float4,Unity.Mathematics.float4)](/engine/7000.0/script-reference/unity/animations/quaternion4/ctor.md#quaternion4\(float4-float4-float4-float4\))                                 | Creates a quaternion4 from four vectors that hold the components of the four quaternions. |
| [quaternion4(Unity.Mathematics.float4x4)](/engine/7000.0/script-reference/unity/animations/quaternion4/ctor.md#quaternion4\(float4x4\))                                                                                                                             | Creates a quaternion4 from the four columns of a matrix.                                  |
| [quaternion4(Unity.Mathematics.quaternion,Unity.Mathematics.quaternion,Unity.Mathematics.quaternion,Unity.Mathematics.quaternion)](/engine/7000.0/script-reference/unity/animations/quaternion4/ctor.md#quaternion4\(quaternion-quaternion-quaternion-quaternion\)) | Creates a quaternion4 from four quaternions.                                              |

## Methods

| Method                                                                                     | Description                                                                                                                   |
| ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
| [Equals](/engine/7000.0/script-reference/unity/animations/quaternion4/equals.md)           | Determines whether this [quaternion4](/engine/7000.0/script-reference/unity/animations/quaternion4.md) equals another object. |
| [GetHashCode](/engine/7000.0/script-reference/unity/animations/quaternion4/gethashcode.md) | Computes a hash code for the quaternion4.                                                                                     |
| [ToString](/engine/7000.0/script-reference/unity/animations/quaternion4/tostring.md)       | Converts the quaternion4 to a string.                                                                                         |

## Operators

| Operator                                                                                   | Description                                              |
| ------------------------------------------------------------------------------------------ | -------------------------------------------------------- |
| [operator +](/engine/7000.0/script-reference/unity/animations/quaternion4/op-addition.md)  | Adds the components of two quaternion4 values.           |
| [operator \*](/engine/7000.0/script-reference/unity/animations/quaternion4/op-multiply.md) | Multiplies every component of a quaternion4 by a scalar. |
