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

# SolveParentConstraint

> Parent constraint solver moves and rotates a constrained bone as if it is the child of another source object. The order source objects are specified does not affect the result.

## Definition

* **Type:** Method
* **Namespace:** [Unity.Animations](/engine/7000.0/script-reference/unity/animations.md)
* **Assembly:** [UnityEngine.AnimationCoreModule](/engine/7000.0/script-reference/modules/unityengine-animationcoremodule.md)

## SolveParentConstraint(AnimationStream, ParentConstraintData, float)

Parent constraint solver moves and rotates a constrained bone as if it is the child of another source object. The order source objects are specified does not affect the result.

```csharp
public static void SolveParentConstraint(ref AnimationStream stream, in Core.ParentConstraintData data, float weight)
```

### Parameters

**** (\[AnimationStream]\(/engine/7000.0/script-reference/unity/animations/animationstream)): The animation stream to apply the solver to.**** (\[ParentConstraintData]\(/engine/7000.0/script-reference/unity/animations/core/parentconstraintdata)): The solver settings. See [Core.ParentConstraintData](/engine/7000.0/script-reference/unity/animations/core/parentconstraintdata.md).**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The overall weight of the solver, clamped to the range from 0 to 1. A weight of 0 leaves the constrained bone unchanged, and a weight of 1 applies the full constraint. Intermediate values blend the position linearly and the rotation with a normalized linear interpolation.

## SolveParentConstraint(AnimationStream, ParentConstraintData, RigidTransform, RigidTransform, float)

Applies a parent constraint to a bone from a single source.

```csharp
public static void SolveParentConstraint(ref AnimationStream stream, in Core.ParentConstraintData data, RigidTransform sourceTransform, RigidTransform sourceOffset, float weight)
```

### Parameters

**** (\[AnimationStream]\(/engine/7000.0/script-reference/unity/animations/animationstream)): The animation stream to apply the solver to.**** (\[ParentConstraintData]\(/engine/7000.0/script-reference/unity/animations/core/parentconstraintdata)): The solver settings. The method uses only [Core.ParentConstraintData.Index](/engine/7000.0/script-reference/unity/animations/core/parentconstraintdata/index.md), [Core.ParentConstraintData.LocalTranslationAxesMask](/engine/7000.0/script-reference/unity/animations/core/parentconstraintdata/localtranslationaxesmask.md), and [Core.ParentConstraintData.LocalRotationAxesMask](/engine/7000.0/script-reference/unity/animations/core/parentconstraintdata/localrotationaxesmask.md), and ignores the source arrays.**** (\[RigidTransform]\(/engine/7000.0/script-reference/unity/mathematics/rigidtransform)): The source transform, in character space. To follow a world-space target, convert it first with `math.mul(math.inverse(characterToWorld), worldTx)`.**** (\[RigidTransform]\(/engine/7000.0/script-reference/unity/mathematics/rigidtransform)): The offset in the local space of the source transform. The solver multiplies it after `sourceTransform`.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): The overall weight of the solver, clamped to the range from 0 to 1. A weight of 0 leaves the constrained bone unchanged, and a weight of 1 applies the full constraint. Intermediate values blend the position linearly and the rotation with a normalized linear interpolation.

### Remarks

Use this overload when the constraint has one source. It gives the same result as [Core.SolveParentConstraint](/engine/7000.0/script-reference/unity/animations/core/solveparentconstraint.md) with one source of weight 1, and you don't need to allocate a [NativeArray\<T>](/engine/7000.0/script-reference/unity/collections/nativearray1.md) for the sources. The method ignores the source arrays in `data`.

The following example uses the `Unity.Animations` and `Unity.Mathematics` namespaces. It converts world-space targets to character space and passes them to the single-source solvers.

### Examples

```csharp
// This example makes a bone aim at a target that lives in world space, for example the position of another entity.
// The constraint solvers work in character space, so the example converts the target first. characterToWorld
// is the character's LocalToWorld transform. Its inverse takes a world-space point to character space.
public static void AimAtWorldTarget(
    ref AnimationStream stream,
    int boneIndex,
    float3 aimAxis,
    RigidTransform characterToWorld,
    float3 worldTarget,
    float weight)
{
    float3 characterTarget = math.transform(math.inverse(characterToWorld), worldTarget);

    // Start from the default settings. The solvers that take a single source ignore the source arrays,
    // so there is nothing to allocate.
    Core.AimConstraintData data = Core.AimConstraintData.Default();
    data.Index = boneIndex;
    data.AimAxis = aimAxis;

    Core.SolveAimConstraint(ref stream, data, characterTarget, quaternion.identity, weight);
}

// A parent constraint follows a world-space transform the same way: multiply the target by the inverse of
// characterToWorld to get a character-space transform.
public static void FollowWorldTransform(
    ref AnimationStream stream,
    int boneIndex,
    RigidTransform characterToWorld,
    RigidTransform worldTarget,
    float weight)
{
    RigidTransform characterTarget = math.mul(math.inverse(characterToWorld), worldTarget);

    Core.ParentConstraintData data = Core.ParentConstraintData.Default();
    data.Index = boneIndex;

    Core.SolveParentConstraint(ref stream, data, characterTarget, RigidTransform.identity, weight);
}

// The position and rotation constraints convert a world-space target the same way.
public static void MoveToWorldPosition(
    ref AnimationStream stream,
    int boneIndex,
    RigidTransform characterToWorld,
    float3 worldPosition,
    float weight)
{
    float3 characterPosition = math.transform(math.inverse(characterToWorld), worldPosition);

    Core.PositionConstraintData data = Core.PositionConstraintData.Default();
    data.Index = boneIndex;

    Core.SolvePositionConstraint(ref stream, data, characterPosition, float3.zero, weight);
}

public static void MatchWorldRotation(
    ref AnimationStream stream,
    int boneIndex,
    RigidTransform characterToWorld,
    quaternion worldRotation,
    float weight)
{
    quaternion characterRotation = math.mul(math.inverse(characterToWorld.rot), worldRotation);

    Core.RotationConstraintData data = Core.RotationConstraintData.Default();
    data.Index = boneIndex;

    Core.SolveRotationConstraint(ref stream, data, characterRotation, quaternion.identity, weight);
}
```
