docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class AnimationRuntimeUtils

    Utility functions for runtime constraints.

    Inheritance
    object
    AnimationRuntimeUtils
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Animations.Rigging
    Assembly: Unity.Animation.Rigging.dll
    Syntax
    public static class AnimationRuntimeUtils

    Methods

    InverseSolveTwoBoneIK(AnimationStream, ReadOnlyTransformHandle, ReadOnlyTransformHandle, ReadOnlyTransformHandle, ReadWriteTransformHandle, ReadWriteTransformHandle, float, float, float, AffineTransform)

    Sets the position for a hint and target given bone positions.

    Declaration
    public static void InverseSolveTwoBoneIK(AnimationStream stream, ReadOnlyTransformHandle root, ReadOnlyTransformHandle mid, ReadOnlyTransformHandle tip, ReadWriteTransformHandle target, ReadWriteTransformHandle hint, float posWeight, float rotWeight, float hintWeight, AffineTransform targetOffset)
    Parameters
    Type Name Description
    AnimationStream stream

    The animation stream to work on.

    ReadOnlyTransformHandle root

    The transform handle for the root transform.

    ReadOnlyTransformHandle mid

    The transform handle for the mid transform.

    ReadOnlyTransformHandle tip

    The transform handle for the tip transform.

    ReadWriteTransformHandle target

    The transform handle for the target transform.

    ReadWriteTransformHandle hint

    The transform handle for the hint transform.

    float posWeight

    The weight for which target position has an effect on IK calculations. This is a value in between 0 and 1.

    float rotWeight

    The weight for which target rotation has an effect on IK calculations. This is a value in between 0 and 1.

    float hintWeight

    The weight for which hint transform has an effect on IK calculations. This is a value in between 0 and 1.

    AffineTransform targetOffset

    The offset applied to the target transform.

    InverseSolveTwoBoneIK(Vector3, Vector3, Vector3, Quaternion, ref Vector3, ref Quaternion, ref Vector3, bool, float, float, float, AffineTransform)

    Sets the position for a hint and target for given bone positions.

    Declaration
    public static void InverseSolveTwoBoneIK(Vector3 rootPosition, Vector3 midPosition, Vector3 tipPosition, Quaternion tipRotation, ref Vector3 targetPosition, ref Quaternion targetRotation, ref Vector3 hintPosition, bool isHintValid, float posWeight, float rotWeight, float hintWeight, AffineTransform targetOffset)
    Parameters
    Type Name Description
    Vector3 rootPosition

    The position of the root bone.

    Vector3 midPosition

    The position of the mid bone.

    Vector3 tipPosition

    The position of the tip bone.

    Quaternion tipRotation

    The rotation of the tip bone.

    Vector3 targetPosition

    The position of the target.

    Quaternion targetRotation

    The rotation of the target.

    Vector3 hintPosition

    The position of the hint.

    bool isHintValid

    Whether the hint position should be set.

    float posWeight

    The weight for which target position has an effect on IK calculations. This is a value in between 0 and 1.

    float rotWeight

    The weight for which target rotation has an effect on IK calculations. This is a value in between 0 and 1.

    float hintWeight

    The weight for which hint transform has an effect on IK calculations. This is a value in between 0 and 1.

    AffineTransform targetOffset

    The offset applied to the target transform.

    Lerp(Vector3, Vector3, Vector3)

    Linearly interpolates between two vectors using a vector interpolant.

    Declaration
    public static Vector3 Lerp(Vector3 a, Vector3 b, Vector3 t)
    Parameters
    Type Name Description
    Vector3 a

    Start Vector3 value.

    Vector3 b

    End Vector3 value.

    Vector3 t

    Interpolant Vector3 value.

    Returns
    Type Description
    Vector3

    Interpolated value.

    PassThrough(AnimationStream, ReadWriteTransformHandle)

    Copies translation, rotation and scale values from specified Transform handle to stream.

    Declaration
    public static void PassThrough(AnimationStream stream, ReadWriteTransformHandle handle)
    Parameters
    Type Name Description
    AnimationStream stream

    The animation stream to work on.

    ReadWriteTransformHandle handle

    The transform handle to copy.

    ProjectOnPlane(Vector3, Vector3)

    Projects a vector onto a plane defined by a normal orthogonal to the plane.

    Declaration
    public static Vector3 ProjectOnPlane(Vector3 vector, Vector3 planeNormal)
    Parameters
    Type Name Description
    Vector3 vector

    The location of the vector above the plane.

    Vector3 planeNormal

    The direction from the vector towards the plane.

    Returns
    Type Description
    Vector3

    The location of the vector on the plane.

    Select(float, float, float)

    Returns b if c is greater than zero, a otherwise.

    Declaration
    public static float Select(float a, float b, float c)
    Parameters
    Type Name Description
    float a

    First float value.

    float b

    Second float value.

    float c

    Comparator float value.

    Returns
    Type Description
    float

    Selected float value.

    Select(Vector3, Vector3, Vector3)

    Returns a componentwise selection between two vectors a and b based on a vector selection mask c. Per component, the component from b is selected when c is greater than zero, otherwise the component from a is selected.

    Declaration
    public static Vector3 Select(Vector3 a, Vector3 b, Vector3 c)
    Parameters
    Type Name Description
    Vector3 a

    First Vector3 value.

    Vector3 b

    Second Vector3 value.

    Vector3 c

    Comparator Vector3 value.

    Returns
    Type Description
    Vector3

    Selected Vector3 value.

    SolveFABRIK(ref NativeArray<Vector3>, ref NativeArray<float>, Vector3, float, float, int)

    Evaluates the FABRIK ChainIK algorithm.

    Declaration
    public static bool SolveFABRIK(ref NativeArray<Vector3> linkPositions, ref NativeArray<float> linkLengths, Vector3 target, float tolerance, float maxReach, int maxIterations)
    Parameters
    Type Name Description
    NativeArray<Vector3> linkPositions

    Uninitialized buffer of positions. linkPositions and linkLengths must have the same size.

    NativeArray<float> linkLengths

    Array of distances in between positions. linkPositions and linkLenghts must have the same size.

    Vector3 target

    Target position.

    float tolerance

    The maximum distance the resulting position and initial target are allowed to have in between them.

    float maxReach

    The maximum distance the Transform chain can reach.

    int maxIterations

    The maximum number of iterations allowed for the ChainIK algorithm to converge to a solution.

    Returns
    Type Description
    bool

    Returns true if ChainIK calculations were successful. False otherwise.

    Remarks

    Implementation of unconstrained FABRIK solver : Forward and Backward Reaching Inverse Kinematic Aristidou A, Lasenby J. FABRIK: a fast, iterative solver for the inverse kinematics problem. Graphical Models 2011; 73(5): 243–260.

    SolveTwoBoneIK(AnimationStream, ReadWriteTransformHandle, ReadWriteTransformHandle, ReadWriteTransformHandle, ReadOnlyTransformHandle, ReadOnlyTransformHandle, float, float, float, AffineTransform)

    Evaluates the Two-Bone IK algorithm.

    Declaration
    public static void SolveTwoBoneIK(AnimationStream stream, ReadWriteTransformHandle root, ReadWriteTransformHandle mid, ReadWriteTransformHandle tip, ReadOnlyTransformHandle target, ReadOnlyTransformHandle hint, float posWeight, float rotWeight, float hintWeight, AffineTransform targetOffset)
    Parameters
    Type Name Description
    AnimationStream stream

    The animation stream to work on.

    ReadWriteTransformHandle root

    The transform handle for the root transform.

    ReadWriteTransformHandle mid

    The transform handle for the mid transform.

    ReadWriteTransformHandle tip

    The transform handle for the tip transform.

    ReadOnlyTransformHandle target

    The transform handle for the target transform.

    ReadOnlyTransformHandle hint

    The transform handle for the hint transform.

    float posWeight

    The weight for which target position has an effect on IK calculations. This is a value in between 0 and 1.

    float rotWeight

    The weight for which target rotation has an effect on IK calculations. This is a value in between 0 and 1.

    float hintWeight

    The weight for which hint transform has an effect on IK calculations. This is a value in between 0 and 1.

    AffineTransform targetOffset

    The offset applied to the target transform.

    SqrDistance(Vector3, Vector3)

    Returns the square length between two vectors.

    Declaration
    public static float SqrDistance(Vector3 lhs, Vector3 rhs)
    Parameters
    Type Name Description
    Vector3 lhs

    Vector3 value.

    Vector3 rhs

    Vector3 value.

    Returns
    Type Description
    float

    Square length between lhs and rhs.

    Square(float)

    Returns the square value of a float.

    Declaration
    public static float Square(float value)
    Parameters
    Type Name Description
    float value

    Float value.

    Returns
    Type Description
    float

    Squared value.

    Sum(NativeArray<float>)

    Calculates the sum of all float elements in the array.

    Declaration
    public static float Sum(NativeArray<float> floatBuffer)
    Parameters
    Type Name Description
    NativeArray<float> floatBuffer

    An array of float elements.

    Returns
    Type Description
    float

    Sum of all float elements.

    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)