Skip to Content

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 GraffityARNavigationRenderer for AR arrows, or draw your own UI from session.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

session.AvailableDestinations lists the POIs of the localized section, as GraffityARPoi objects with PoiId, DisplayName, Category, SectionId, PlaceId and MapPosition. The list is filled after the first localization.

To place your own marker at a POI, session.TryGetWorldPosition(poi, out var world) returns its world position once the POI’s section root is aligned. You never flip axes yourself.

Step 2 - Start navigation

Pass a destination from the list, or its PoiId:

var destination = session.AvailableDestinations.First(d => d.DisplayName == "Food Court"); await session.StartNavigationAsync(destination); // or: await session.StartNavigationAsync(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, session.State.Navigation is a GraffityARNavigationState:

PropertyDescription
DestinationId, DestinationNameThe final destination, even while the current leg heads to a lift or stairs
ActionThe next maneuver: Forward, TurnLeft, TurnRight, GoUp, GoDown or Arriving
DistanceToDestinationMetersRemaining route distance
DistanceToNextActionMetersDistance to the next maneuver, or null

Observe it with the StateChanged event, 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 the arrival radius from your project’s SDK settings, the session raises NavigationArrived once and ends the route. Call session.StopNavigation() to cancel; the session raises NavigationStopped. 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:

  1. Localization pauses, the previous section’s content is hidden, and session.PendingTransition becomes non-null. It is a GraffityARSectionTransition with:
    • NextSectionName: the section to go to, for example “Floor 3”.
    • GoingUp: true, false or null if unknown.
    • Hop: the transition details, including Type, FromPoiName and ToPoiName.
  2. Show your own prompt, for example “Take the lift to Floor 3, then tap Continue”.
  3. After the player has changed floors, call session.ContinueAfterTransition(). The SDK localizes again in the new section and continues to the final destination.
var transition = session.PendingTransition; if (transition != null) { prompt.text = $"Go {(transition.GoingUp == true ? "up" : "down")} to {transition.NextSectionName}"; continueButton.onClick.AddListener(session.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 GraffityARNavigationRenderer

GraffityARNavigationRenderer is an optional component that draws route arrows and a destination marker from your own prefabs.

  1. Import the Navigation visuals sample from the Package Manager and choose Tools > Graffity AR Cloud > Samples > Create navigation visuals. This creates URP arrow, marker and renderer prefabs in your Assets folder.
  2. Add the renderer prefab to your scene, outside any map root.
  3. Assign it to the session’s Navigation Renderer field. The session attaches it to the XR Origin’s tracking space when it initializes.
FieldDescription
Navigation Arrow PrefabPath arrow. Local +Z points forward and +Y points up.
Destination Icon PrefabMarker shown at the destination
Destination Go Up / Go Down PrefabOptional markers at transition points
MaterialOptional material override for the instances
Navigation Arrow CountNumber of arrows ahead of the player (1–32, default 3)
Enable Fixed Nav ArrowShow a fixed guide arrow in front of the camera
View CameraCamera used to hide arrows outside the view. Defaults to the XR Origin camera.

To set the prefabs from code, call renderer.Configure(arrowPrefab, destinationPrefab) before the session initializes. The renderer owns the objects it instantiates and destroys them when it is released. Your prefabs and materials aren’t modified. Leave the session field empty to draw navigation entirely yourself.

Try it in the Editor

In Play Mode, the session Inspector’s Editor simulation section can localize, start navigation to any destination and walk the camera along the route, so you can check your navigation UI and arrows without going on site. See Test in the Editor.

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 Tools > Graffity AR Cloud > 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.