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

# SocketNode

> The representation of a socket in the animation rig.

## 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)

```csharp
public struct SocketNode
```

## Remarks

A socket is a fixed transform relative to a bone, for example the place where a character holds a weapon. Add sockets with [RigBuilder.Add](/engine/7000.0/script-reference/unity/animations/rigbuilder/add.md). The animation stream has no channel for a socket, so the socket moves only with its parent bone.

The following example uses the `Unity.Animations`, `Unity.Collections`, `Unity.Entities`, and `Unity.Mathematics` namespaces. It adds a socket to the hand of an arm rig, then reads the transform of the socket in character space from an animation stream.

## Examples

```csharp
// This example adds a socket for a sword to the hand of a two-bone arm, then reads where the sword is in
// character space for the pose in an animation stream.
public static readonly StringHash SwordSocketId = new StringHash("Sword");

// Builds the arm rig with the sword socket. The caller owns the returned rig definition and must dispose it.
public static BlobObjectReference<RigDefinition> BuildArmRigWithSocket()
{
    using RigBuilder rigBuilder = new RigBuilder(Allocator.Temp);

    // Bone 0 is the shoulder. Bone 1 is the hand, one unit from the shoulder along the x-axis.
    rigBuilder.Add(new SkeletonNode
    {
        Id = "Shoulder",
        ParentIndex = -1,
        LocalTranslationDefaultValue = float3.zero,
        LocalRotationDefaultValue = quaternion.identity,
        LocalScaleDefaultValue = new float3(1f)
    });
    rigBuilder.Add(new SkeletonNode
    {
        Id = "Hand",
        ParentIndex = 0,
        LocalTranslationDefaultValue = new float3(1f, 0f, 0f),
        LocalRotationDefaultValue = quaternion.identity,
        LocalScaleDefaultValue = new float3(1f)
    });

    // A socket is a fixed transform relative to a bone. The animation stream has no channel for a socket, so
    // the socket moves only with its parent bone. BoneParentIndex is the index of the parent bone, in the
    // order that you add the bones. The sword is 0.25 units from the hand along the x-axis of the hand.
    rigBuilder.Add(new SocketNode
    {
        Id = SwordSocketId,
        BoneParentIndex = 1,
        LocalTranslationValue = new float3(0.25f, 0f, 0f),
        LocalRotationValue = quaternion.identity,
        LocalScaleValue = new float3(1f)
    });

    return rigBuilder.ToRigDefinition();
}

// Reads the transform of a socket in character space. Returns false if the rig has no socket with that
// identifier.
public static bool TryGetSocketInCharacterSpace(
    in AnimationStream stream,
    StringHash socketId,
    out float3 translation,
    out quaternion rotation)
{
    // Search the sockets of the rig of the stream. FindSocketIndex returns -1 when there is no match.
    int socketIndex = BindingUtility.FindSocketIndex(ref stream.RigDefinition.SocketValues, socketId);
    if (socketIndex < 0)
    {
        translation = float3.zero;
        rotation = quaternion.identity;
        return false;
    }

    // Apply the socket transform to the character space transform of its parent bone in the stream.
    // When the stream rotates the shoulder by 90 degrees around the z-axis, the sword is at (0, 1.25, 0).
    stream.GetSocketLocalToCharacterTR(socketIndex, out translation, out rotation);
    return true;
}
```

## Fields

| Value                                                                                                         | Description                                                                                    |
| ------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| [BoneParentIndex](/engine/7000.0/script-reference/unity/animations/socketnode/boneparentindex.md)             | Parent [SkeletonNode](/engine/7000.0/script-reference/unity/animations/skeletonnode.md) index. |
| [Id](/engine/7000.0/script-reference/unity/animations/socketnode/id.md)                                       | Unique identifier.                                                                             |
| [LocalRotationValue](/engine/7000.0/script-reference/unity/animations/socketnode/localrotationvalue.md)       | Default rotation values.                                                                       |
| [LocalScaleValue](/engine/7000.0/script-reference/unity/animations/socketnode/localscalevalue.md)             | Default scale values.                                                                          |
| [LocalTranslationValue](/engine/7000.0/script-reference/unity/animations/socketnode/localtranslationvalue.md) | Default translation values.                                                                    |
