Navigation
After the device localizes, the SDK can guide the player to a point of interest (POI) along the section’s navigation graph. Routes can cross sections, for example by taking a lift to another floor. The SDK computes the route and guidance. You decide how to present it: use the optional NavigationRenderer for AR arrows, or draw your own UI from sdk.state.navigation.
Navigation data comes from your map in Graffity Console. There is no built-in destination picker, so your game chooses the destination.
Start a route
Step 1 - Wait for localization
sdk.availableDestinations lists the POIs of the localized section, as PickedDestination objects with poiId, displayName, category, sectionId, placeId and position. The list is filled after the first localization.
Step 2 - Start navigation
Pass a destination from the list, or its poiId:
var sdk = session.sdk;
var destination = sdk.availableDestinations.First(d => d.displayName == "Food Court");
await sdk.startNavigation(destination); // or: await sdk.startNavigation(destination.poiId);The returned Task completes when the route is accepted, not when the player arrives. It faults with a GraffityARCloudError when no route is available, for example navigationGraphUnavailable or navigationRouteUnavailable.
Step 3 - Follow the guidance
While a route is active, sdk.state.navigation is a GraffityARNavigationState:
| Property | Description |
|---|---|
destinationId, destinationName | The final destination, even while the current leg heads to a lift or stairs |
action | The next maneuver: forward, turnLeft, turnRight, goUp, goDown or arriving |
distanceToDestinationMeters | Remaining route distance |
distanceToNextActionMeters | Distance to the next maneuver, or null |
Observe it with statePublisher or the delegate’s didChangeState, like any other state. If the player leaves the route by more than 3 m, the SDK recomputes it.
Step 4 - Arrive or stop
Within 3 m of the destination, the SDK calls didArriveAt on the delegate once and ends the route. Call sdk.stopNavigation() to cancel; the delegate receives graffityARCloudDidStopNavigation. Starting a new destination replaces the current route.
Multi-section journeys
When the destination is in another section of the same place, the route leads to a transition point, such as a lift, an escalator or stairs. When the player reaches it:
- Localization pauses and
sdk.pendingTransitionbecomes non-null. It is anAwaitingSectionTransitionwith:nextSectionName: the section to go to, for example “Floor 3”.goingUp:true,falseornullif unknown.hop: the transition details, includingtype,fromPoiNameandtoPoiName.
- Show your own prompt, for example “Take the lift to Floor 3, then tap Continue”.
- After the player has changed floors, call
sdk.continueAfterTransition(). The SDK localizes again in the new section and continues to the final destination.
var transition = session.sdk.pendingTransition;
if (transition != null)
{
prompt.text = $"Go {(transition.goingUp == true ? "up" : "down")} to {transition.nextSectionName}";
continueButton.onClick.AddListener(() => session.sdk.continueAfterTransition());
}If the player ends up in a different section than expected, the SDK plans the rest of the route from the section it actually detects. Before starting a new destination during a transition, call continueAfterTransition() or stopNavigation().
Routes work across sections within one place. Routes between different places aren’t supported and fail with navigationRouteUnavailable.
AR arrows with NavigationRenderer
NavigationRenderer is an optional component that draws route arrows and a destination marker from your own prefabs.
- Import the Navigation visuals sample from the Package Manager and choose
Graffity>AR Cloud>Samples>Create navigation visuals. This creates URP arrow, marker and renderer prefabs in yourAssetsfolder. - Add the renderer prefab to your scene, outside any map root.
- Assign it to the session’s Navigation Renderer field. The session attaches it to the XR Origin’s tracking space when it initializes.
| Field | Description |
|---|---|
| Navigation Arrow Prefab | Path arrow. Local +Z points forward and +Y points up. |
| Destination Icon Prefab | Marker shown at the destination |
| Destination Go Up / Go Down Prefab | Optional markers at transition points |
| Material | Optional material override for the instances |
| Navigation Arrow Count | Number of arrows ahead of the player (1–32, default 3) |
| Enable Fixed Nav Arrow | Show a fixed guide arrow in front of the camera |
| View Camera | Camera used to hide arrows outside the view. Defaults to the XR Origin camera. |
The renderer owns the objects it instantiates and destroys them when it is released. Your prefabs and materials aren’t modified. Leave the field empty to draw navigation entirely yourself.
Sample
The Host integration sample includes ScriptedNavigation, which drives navigation from scripts, and NavigationUIController, an example destination list and Continue button in English and Thai. Use Graffity > Samples > Create scripted navigation integration scene to create a scene with both. The UI is optional; delete it and call the same API from your own UI.