---
title: Core.TwoBoneIKData
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/core/twoboneikdata
latest_url: https://docs.unity.com/en-us/engine/7000.0/script-reference/unity/animations/core/twoboneikdata.md
last_updated: 2026-11-30
generated_at: 2026-11-30T21:09:53.863Z
locale: en-us
---

# Core.TwoBoneIKData

> 2-bone IK solver settings.

## 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 Core.TwoBoneIKData
```

## Remarks

The following example is a `MonoBehaviour` that plays a clip and makes an arm reach for a target, which it converts from world space to character space.

The last code block is the Burst-compiled function that writes the pose to the transforms. The function isn't part of the API, so copy it into your project.

\`\`\<!\[CDATA\[using Unity.Burst; using Unity.Collections; using Unity.Mathematics; using UnityEngine;

namespace Unity.Animations.DocumentationExamples \{ // Writes the pose in a stream to the transform handles that // RigDefinitionUtility.BindTransforms outputs. Entry index of the // handles is the transform of bone index. \[BurstCompile] public static class WriteTransformsUtility \{ // A Burst-compiled static method runs on the main thread, so it // writes the transforms without the cost of scheduling a job. \[BurstCompile] public static void WriteTransforms( in AnimationStream stream, in NativeArray\<TransformHandle> transforms) \{ for (int i = 0; i \< transforms.Length; ++i) \{ // The entry of a bone that has no transform is None, and a // destroyed transform is no longer valid. TransformHandle transform = transforms\[i]; if (!transform.IsValid()) \{ continue; }

stream.GetLocalToParentTRS( i, out float3 translation, out quaternion rotation, out float3 scale); transform.SetLocalPositionAndRotation(translation, rotation); transform.localScale = scale; } } } } ]]>

## Examples

```csharp
using Unity.Collections;
using Unity.IntegerTime;
using Unity.Mathematics;
using UnityEngine;

namespace Unity.Animations.DocumentationExamples
{
    // This example plays a clip and makes an arm reach for a target with two-bone IK, for example a door handle that
    // the character grabs. Assign a clip that animates the transforms under the GameObject of this component, with
    // paths relative to this GameObject, including the bones of the arm. Then assign the skeleton root, the top bone
    // of the skeleton, a direct child of this GameObject. Assign the bones of the arm and the target. Optionally,
    // assign a hint that the elbow bends towards.
    public class ArmReachExample : MonoBehaviour
    {
        public AnimationClip clip;
        public Transform skeletonRootTransform;
        public Transform upperArm;
        public Transform forearm;
        public Transform hand;
        public Transform target;
        public Transform elbowHint;
        [Range(0f, 1f)] public float ikWeight = 1f;

        // When true, the hand also turns to the rotation of the target, for example to grip a handle. When false, the
        // hand keeps the rotation of the clip.
        public bool matchTargetRotation = true;

        BlobObjectReference<RigDefinition> m_RigDefinition;
        NativeArray<TransformHandle> m_BoneTransforms;
        ClipSampler m_Sampler;
        int m_UpperArmIndex;
        int m_ForearmIndex;
        int m_HandIndex;
        float m_Time;

        void OnEnable()
        {
            if (clip == null || skeletonRootTransform == null)
                return;

            // The reference keeps the rig definition alive until you dispose it.
            using RigBuilder rigBuilder = RigBuilder.Create(
                transform, skeletonRootTransform, new[] { clip }, Allocator.Temp);
            m_RigDefinition = rigBuilder.ToRigDefinition();
            RigDefinitionUtility.BindTransforms(
                ref m_RigDefinition.Value, transform, Allocator.Persistent, out m_BoneTransforms);
            m_Sampler = clip.ToClipSampler(ref m_RigDefinition.Value, Allocator.Persistent);

            // Find the bones of the arm once. The bound transforms are indexed by bone index, and a transform that
            // isn't a bone of the rig has the index -1.
            m_UpperArmIndex = FindBoneIndex(upperArm);
            m_ForearmIndex = FindBoneIndex(forearm);
            m_HandIndex = FindBoneIndex(hand);
            m_Time = 0f;
        }

        void OnDisable()
        {
            // Dispose the sampler before the rig definition that it uses.
            if (m_Sampler.IsCreated)
                m_Sampler.Dispose();
            if (m_BoneTransforms.IsCreated)
                m_BoneTransforms.Dispose();
            m_RigDefinition.Dispose();
        }

        void Update()
        {
            m_Time += Time.deltaTime;
            ApplyPose(m_Time);
        }

        // Samples the clip at a time, moves the hand to the target, and writes the pose to the transforms.
        public void ApplyPose(float time)
        {
            if (!m_Sampler.IsCreated)
                return;

            AnimationStream stream = AnimationStream.Create(ref m_RigDefinition.Value, Allocator.Temp);
            m_Sampler.Sample(ref stream, new DiscreteTime(time));

            if (target != null && m_UpperArmIndex >= 0 && m_ForearmIndex >= 0 && m_HandIndex >= 0)
            {
                // The upper arm, the forearm, and the hand form the limb. The target and the hint are in character
                // space, so convert them from world space.
                Core.TwoBoneIKData ik = Core.TwoBoneIKData.Default();
                ik.RootIndex = m_UpperArmIndex;
                ik.MidIndex = m_ForearmIndex;
                ik.TipIndex = m_HandIndex;
                ik.Target = new RigidTransform(
                    Quaternion.Inverse(transform.rotation) * target.rotation,
                    transform.InverseTransformPoint(target.position));

                // The default settings turn the hand to the rotation of the target. A rotation weight of 0 keeps the
                // rotation of the hand from the clip, relative to the character.
                ik.TargetRotationWeight = matchTargetRotation ? 1f : 0f;

                // Without a hint, the solver keeps the elbow in the plane in which the arm bends in the clip. A hint
                // pulls the elbow towards a point, for example behind and below the shoulder.
                if (elbowHint != null)
                {
                    ik.Hint = transform.InverseTransformPoint(elbowHint.position);
                    ik.HintWeight = 1f;
                }

                // The weight blends between the pose of the clip, at 0, and the solved pose, at 1. Raise it over a few
                // frames when the character starts to reach, so the arm doesn't jump.
                Core.SolveTwoBoneIK(ref stream, ik, ikWeight);
            }

            // Write the pose to the transforms with a Burst-compiled function. The function isn't part of the API,
            // so copy it into your project.
            WriteTransformsUtility.WriteTransforms(stream, m_BoneTransforms);

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

        // Returns the bone index of a transform, or -1 if no bone has the transform.
        int FindBoneIndex(Transform bone)
        {
            if (bone == null)
                return -1;
            for (int i = 0; i < m_BoneTransforms.Length; ++i)
            {
                if (m_BoneTransforms[i] == bone.transformHandle)
                    return i;
            }
            return -1;
        }
    }
}
```

## Fields

| Value                                                                                                               | Description                                                                                                                                                                                                                                                                                       |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Hint](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/hint.md)                                 | Optional source position specified in LocalToCharacter space to describe the direction the limb should be oriented when it bends.                                                                                                                                                                 |
| [HintWeight](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/hintweight.md)                     | The amount of influence the hint has on the configuration of the hierarchy. When set to 1, the hint fully influences the hierarchy configuration. Set to 0 if the hint should be ignored.                                                                                                         |
| [MidIndex](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/midindex.md)                         | Middle index of the limb hierarchy. It must be a child of the root bone.                                                                                                                                                                                                                          |
| [RootIndex](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/rootindex.md)                       | Root index of the limb hierarchy.                                                                                                                                                                                                                                                                 |
| [Target](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/target.md)                             | Source transform specified in LocalToCharacter space that defines the desired location of the tip bone.                                                                                                                                                                                           |
| [TargetOffset](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/targetoffset.md)                 | Specifies an offset on the target to maintain when solving the limbs.                                                                                                                                                                                                                             |
| [TargetPositionWeight](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/targetpositionweight.md) | The weight to apply for calculating the desired position when reaching for the target. If set to 1, the root and mid bones will extend as far as necessary to try to reach the specified target position. As with the constraint's overall weight, intermediate values are interpolated linearly. |
| [TargetRotationWeight](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/targetrotationweight.md) | The weight of the rotation applied to the tip. If set to 1, the tip aligns its rotation to the specified target. As with the constraint's overall weight, intermediate values are interpolated linearly.                                                                                          |
| [TipIndex](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/tipindex.md)                         | Tip index of the limb hierarchy. It must be a child of the mid bone.                                                                                                                                                                                                                              |

## Static Methods

| Method                                                                                    | Description                                               |
| ----------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [Default](/engine/7000.0/script-reference/unity/animations/core/twoboneikdata/default.md) | Returns a set of default values for the TwoBoneIK solver. |
