docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Ray casts

    This page is a supplement to the AR Foundation Ray casts manual. The following sections only contain information about APIs where ARCore exhibits unique platform-specific behavior.

    Tip

    When developing an AR app, refer to both the AR Foundation documentation as well as the required packages for each platform you support.

    Optional feature support

    ARCore implements the following optional features of AR Foundation's XRRaycastSubsystem:

    Feature Descriptor Property Supported
    Viewport based raycast supportsViewportBasedRaycast Yes
    World based raycast supportsWorldBasedRaycast Yes
    Tracked raycasts supportsTrackedRaycasts Yes

    Supported trackables

    ARCore supports ray casting against the following trackable types:

    TrackableType Supported
    BoundingBox
    Depth Yes
    Face
    FeaturePoint Yes
    Image
    Planes Yes
    PlaneEstimated Yes
    PlaneWithinBounds Yes
    PlaneWithinInfinity
    PlaneWithinPolygon Yes
    Note

    Refer to AR Foundation Ray cast platform support for more information on the optional features of the Raycast subsystem.

    Native pointer

    XRRaycast.nativePtr values returned by this package contain a pointer to the following struct:

    typedef struct UnityXRNativeRaycast
    {
        int version;
        void* instantPoint;
        void* anchor;
    } UnityXRNativeRaycast;
    

    This package also provides a header file containing the definitions of various native data structs including UnityXRNativeRaycast. It can be found in the package directory under Includes~/UnityXRNativePtrs.h.

    Cast void* instantPoint to an ArTrackable and void* anchor to an ArAnchor handle in C++ using the following example code:

    // Marhshal the native ray cast data from XRRaycast.nativePtr in C#
    UnityXRNativeRaycast nativeRaycastData;
    ArTrackable* pointTrackableHandle = static_cast<ArTrackable*>(nativeRaycastData.instantPoint);
    ArAnchor* anchorHandle = static_cast<ArAnchor*>(nativeRaycastData.anchor);
    

    To learn more about native pointers and their usage, refer to Extending AR Foundation.

    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)