docs.unity.cn
Search Results for

    Show / Hide Table of Contents

    Method TryGetPose

    TryGetPose(out Pose)

    Retrieves the joint's pose, if available.

    Declaration
    public bool TryGetPose(out Pose pose)
    Parameters
    Type Name Description
    Pose pose

    Assigned the tracked pose of this joint, if successful. Set to identity, if unsuccessful.

    Returns
    Type Description
    bool

    Returns true if successful and the joint pose was filled out with valid tracking data, returns false otherwise.

    Remarks

    Joint poses are relative to the real-world point chosen by the user's device.

    To transform to world space so that the joint appears in the correct location relative to the user, transform the pose based on the XROrigin.

    Examples

    The following example illustrates how to transform a pose into world space using the transform from the XROrigin object in a scene.

    public Pose ToWorldPose(XRHandJoint joint, Transform origin)
    {
        Pose xrOriginPose = new Pose(origin.position, origin.rotation);
        if (joint.TryGetPose(out Pose jointPose))
        {
            return jointPose.GetTransformedBy(xrOriginPose);
        }
        else
        {
            return Pose.identity;
        }
    }
    In This Article
    Back to top
    Copyright © 2023 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)