Develop

Spatial Anchors Unreal C++ Reference

Updated: Apr 14, 2026
This page provides the C++ API reference for the OculusXRAnchors module. All functions listed below are static methods on OculusXRAnchors::FOculusXRAnchors. To use them, include the following header:
#include "OculusXRAnchors.h"
Functions that return bool indicate whether the async request was successfully submitted to the platform. A return value of true means the request was accepted and the result will arrive via the delegate callback. A return value of false means the request failed to start. Check the OutResult parameter for the immediate return code when the request fails. The two group-based functions, ShareAnchorsAsync and GetSharedAnchorsAsync, return a TSharedPtr to an async request object instead of bool.

Anchor Types

FOculusXRUUID

FunctionDescription
IsValidUUID
True if this UUID is non-zero.
ToString
Converts the internal UUID representation into a string you can print.

FOculusXRUInt64

FunctionDescription
GetValue
Returns the internal uint64.
SetValue
Sets the internal uint64.

FOculusXRSpaceDiscoveryInfo

VariableDescription
Filters
The list of filters to use in a discovery request.

FOculusXRAnchorsDiscoverResult

VariableDescription
Space
The anchor handle for the discovered anchor.
UUID
The persistent UUID for the discovered anchor.

UOculusXRSpaceDiscoveryIdsFilter

VariableDescription
Uuids
The list of UUIDs to find during the discovery request.

UOculusXRSpaceDiscoveryComponentsFilter

VariableDescription
ComponentType
The component type that must be present on any anchor returned during the discovery request.

Delegate Types

DelegateParameters
FOculusXRSpatialAnchorCreateDelegate
EOculusXRAnchorResult::Type Result,
UOculusXRAnchorComponent* Anchor
FOculusXRSaveAnchorsDelegate
EOculusXRAnchorResult::Type Result,
const TArray<UOculusXRAnchorComponent*>& SavedAnchors
FOculusXREraseAnchorsDelegate
EOculusXRAnchorResult::Type Result,
const TArray<UOculusXRAnchorComponent*>& ErasedAnchors,
const TArray<FOculusXRUInt64>& ErasedAnchorHandles,
const TArray<FOculusXRUUID>& ErasedAnchorUUIDs
FOculusXRDiscoverAnchorsResultsDelegate
const TArray<FOculusXRAnchorsDiscoverResult>& DiscoveredAnchors
FOculusXRDiscoverAnchorsCompleteDelegate
EOculusXRAnchorResult::Type Result
FOculusXRAnchorShareDelegate
EOculusXRAnchorResult::Type Result,
const TArray<UOculusXRAnchorComponent*>& Anchors,
const TArray<uint64>& Users
FOculusXRGetSharedAnchorsDelegate
EOculusXRAnchorResult::Type Result,
const TArray<FOculusXRAnchorsDiscoverResult>& Results

Function Signatures

Create Spatial Anchor

bool CreateSpatialAnchor(
   const FTransform& InTransform,
   AActor* TargetActor,
   const FOculusXRSpatialAnchorCreateDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
InTransform
The world space location to attempt to create the anchor at.
TargetActor
The Actor to attach the created spatial anchor to.
ResultCallback
The callback executed when the create succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Save Spatial Anchors

bool SaveAnchors(
   const TArray<UOculusXRAnchorComponent*>& Anchors,
   const FOculusXRSaveAnchorsDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
Anchors
The list of anchors to save.
ResultCallback
The callback executed when the save succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Discover Spatial Anchors

bool DiscoverAnchors(
   const FOculusXRSpaceDiscoveryInfo& DiscoveryInfo,
   const FOculusXRDiscoverAnchorsResultsDelegate& DiscoveryResultsCallback,
   const FOculusXRDiscoverAnchorsCompleteDelegate& DiscoveryCompleteCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
DiscoveryInfo
The structure containing the list of filters to apply to the discovery request.
DiscoveryResultsCallback
The callback executed every time anchors are found. Can fire zero or more times.
DiscoveryCompleteCallback
The callback executed once the discovery request is complete.
OutResult
The non-async immediate return code after starting the call.

Erase Spatial Anchors by Component

bool EraseAnchors(
   const TArray<UOculusXRAnchorComponent*>& Anchors,
   const FOculusXREraseAnchorsDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
Anchors
The list of anchors to erase.
ResultCallback
The callback executed when the erase succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Erase Spatial Anchors by UUID or AnchorHandle

bool EraseAnchors(
   const TArray<FOculusXRUInt64>& AnchorHandles,
   const TArray<FOculusXRUUID>& AnchorUUIDs,
   const FOculusXREraseAnchorsDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
AnchorHandles
The list of AnchorHandles associated with anchors you intend to erase.
AnchorUUIDs
The list of AnchorUUIDs associated with anchors you intend to erase.
ResultCallback
The callback executed when the erase succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Destroy Spatial Anchor

bool DestroyAnchor(
   uint64 AnchorHandle,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
AnchorHandle
The handle to the anchor you want to destroy.
OutResult
The non-async immediate return code after starting the call.

Share Spatial Anchors

bool ShareAnchors(
   const TArray<UOculusXRAnchorComponent*>& Anchors,
   const TArray<uint64>& OculusUserIDs,
   const FOculusXRAnchorShareDelegate& ResultCallback,
   EOculusXRAnchorResult::Type& OutResult);
InputDescription
Anchors
The list of anchors to share.
OculusUserIDs
The list of users to share the specified anchors with. Each uint64 is a User ID.
ResultCallback
The callback executed when the share succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Share Spatial Anchors with Group

TSharedPtr<FShareAnchorsWithGroups> ShareAnchorsAsync(
   const TArray<FOculusXRUInt64>& AnchorHandles,
   const TArray<FOculusXRUUID>& Groups,
   const FShareAnchorsWithGroups::FCompleteDelegate& OnComplete);
InputDescription
AnchorHandles
The list of anchors to share.
Groups
The list of groups to share the specified anchors with.
OnComplete
The callback executed when the share succeeds or fails.
OutputDescription
TSharedPtr<FShareAnchorsWithGroups>
The resulting async request object.

Get Shared Spatial Anchors

bool GetSharedAnchors(
    const TArray<FOculusXRUUID>& AnchorUUIDs,
    const FOculusXRGetSharedAnchorsDelegate& ResultCallback,
    EOculusXRAnchorResult::Type& OutResult);
InputDescription
AnchorUUIDs
The list of anchors to attempt to retrieve.
ResultCallback
The callback executed when the request succeeds or fails.
OutResult
The non-async immediate return code after starting the call.

Get Shared Spatial Anchors from Group

TSharedPtr<FGetAnchorsSharedWithGroup> GetSharedAnchorsAsync(
   const FOculusXRUUID& Group,
   const TArray<FOculusXRUUID>& WantedAnchors,
   const FGetAnchorsSharedWithGroup::FCompleteDelegate& OnComplete);
InputDescription
Group
The group to retrieve anchors from.
WantedAnchors
The list of specific anchor UUIDs to retrieve from the group. Pass an empty array to retrieve all anchors.
OnComplete
The callback executed when the request succeeds or fails.
OutputDescription
TSharedPtr<FGetAnchorsSharedWithGroup>
The resulting async request object.

Learn more