Placing Virtual Content with VPS2
Anchors are persistent spatial reference points that can be shared and resolved across sessions and devices. The VPS2 session manages their lifecycle and maintains the relationship between each anchor’s map-relative pose and its corresponding global geoposition.
Prerequisites
This guide assumes that you have already completed:
Creating Anchors
The TryCreateAnchor method creates a persistent anchor tied to visual features at the specified pose and returns an ARPersistentAnchor GameObject. The pose provided when creating an anchor is expressed in the current local AR coordinate frame. Do not manually modify the anchor’s transform; it is updated automatically by VPS2.
if (vps2Manager.TryCreateAnchor(pose, out var anchorOut)) {
// Attach virtual content as a child of anchorOut
}
Getting Anchor Payloads
An anchor payload encodes the data required to resolve the anchor across devices or sessions. It is a base64-encoded string. The payload becomes available only after the anchor has been sufficiently resolved against its originating VPS map.
Anchor payloads are map-specific and can only be precisely resolved against the map on which they were created. If resolved outside that map, the anchor may only achieve coarse positioning based on global geoposition.
Anchor payloads can be obtained from:
-
Default anchors of published Sites (via the “Anchor Payload” field in the Site’s Assets view)
-
User-generated anchors:
TryGetAnchorPayload(anchorId: UUID)
if (vps2Manager.TryGetAnchorPayload(anchor, out string payload)) {
// Your logic here
}
Updating Anchors
After creating or tracking an anchor (ARVps2Manager.TryCreateAnchor or ARVps2Manager.TryTrackAnchor), the transform of the ARPersistentAnchor component is updated automatically. You may also subscribe to change events:
vps2Manager.trackablesChanged.AddListener(OnTrackablesChanged);
Understanding anchor tracking states
VPS2 exposes two tracking states for anchors:
-
Limited: The anchor pose is estimated using coarse localization. The pose is usable for approximate placement but may drift and does not provide centimeter-level alignment.
-
Tracked: The device is localized to a VPS map, and the anchor pose is resolved relative to that VPS map with centimeter-level accuracy.
These states describe the accuracy of the anchor’s pose in the local AR coordinate frame. They are independent of the VPS2 transformer’s geographic tracking state, which governs the accuracy of geoposition-based conversions.
An anchor may transition from Limited to Tracked once the device localizes to the underlying VPS map. If map localization is lost, a Tracked anchor may revert to Limited. If precise AR alignment is required, your application should wait until the anchor reaches the Tracked state.
Removing Anchors
Once removed, an anchor stops receiving updates and no longer consumes processing resources.
vps2Manager.TryRemoveAnchor(_anchor);