For the complete documentation index, see llms.txt. This page is also available as Markdown.

NavMesh Navigation

Details on how to add NavMesh Navigation in MultiSet Unity SDK

Unity's NavMesh system and MultiSet localization work together with no runtime coordinate maths. Bake the NavMesh once in the Editor with your map mesh parented under MapSpace, and it will follow the map into the real world every time the device localizes.

You do not need to re-bake the NavMesh at runtime, and you do not need to convert positions with InverseTransformPoint. Step 5 below explains why.

1. Import 3D Mesh from Developer Portal

Download the 3D Mesh (.glb) of a Map or MapSet from the Developer Portal and import it into Unity (under MapSpace Gameobject)

2. Add Unity NavMesh Surface component to this Mesh

Install Unity NavMesh package: com.unity.ai.navigation Select the Mesh -> Component -> Navigation -> NavMesh Surface

3. Bake the NavMesh Surface

Once NavMesh Surface component is added, adjust the NavMesh settings as per your scan under Window -> AI -> Navigation, and then select the Mesh and click on bake.

4. Check the baked surface

  • Check the baked surface; the blue colour is the detected path that is used later in finding paths. You can adjust the NavMesh surface setting based on your map scan area.

  • In some areas of the Mesh ground might not be accurate, in those cases, place planes inside the map just slightly above the ground those planes are just used for NavMesh baking and need to be deactivated later

5. How the NavMesh follows real-world localization

This step is not something you implement. It describes what the SDK and Unity already do for you, so that you do not write code you do not need.

What happens on localization

When localization succeeds, the MultiSet SDK sets the position and rotation of the MapSpace GameObject so that it aligns with the physical space. Everything parented under MapSpace moves with it, including your map mesh and the NavMesh Surface component on it.

Why the baked NavMesh moves with it

Unity's NavMeshSurface component (from com.unity.ai.navigation) registers itself with the navigation system and watches its own transform. When that transform's position or rotation changes, the component removes its baked NavMesh instance and re-adds it at the new pose. Because your NavMesh Surface is a child of MapSpace, this happens automatically the moment MapSpace is moved by localization. The baked data itself is never rebuilt, it is only re-placed, so the cost is negligible.

The practical consequences:

  • The walkable surface lines up with the real world as soon as you localize.

  • Your NavMeshAgent (on the AR camera) and your destinations (parented under MapSpace) are already expressed in the same Unity world space, so agent.destination = poi.transform.position is all you need.

  • Do not call NavMeshSurface.BuildNavMesh() at runtime. Re-baking on device is slow and unnecessary.

  • Do not convert positions with Transform.InverseTransformPoint or Transform.TransformPoint for navigation. That conversion is only required when a coordinate has to leave the Unity scene graph, for example when it is sent over a network or saved to a backend. See Multiplayer AR for that case.

Recalculating a path after localization

The NavMesh instance is re-placed during Unity's navigation pre-update, so it is correctly positioned from the frame after MapSpace moves. If you calculate a path in the same frame that localization succeeds, that query can still run against the previous placement. Recalculate from the LocalizationSuccess event, one frame later:

You can also wire this up without code by dragging your script's method onto the LocalizationSuccess UnityEvent in the Inspector. See the MapLocalizationManager API reference for the full list of events.

If background localization is enabled, MapSpace is re-aligned on every successful localization, not just the first one. The NavMesh follows each time. Any world position you cached yourself will go stale, so read positions from the transforms under MapSpace instead of caching Vector3 values.

6. Add a Navigation sample in NavMesh

Attaching the Agent

To set up agent navigation in your AR or camera-based scene, you'll need to follow these key steps:

Camera Attachment

Attach the navigation agent to the Main Camera or the primary camera used for the AR session. This ensures the agent's navigation is synchronized with the user's device perspective.

Path Rendering

By default, agents will continuously move towards their destination. To visualize the path without actual movement, you'll need to:

  1. Stop the agent's movement using the isStopped property

  2. Use the LineRenderer component to draw the calculated navigation path

LineRenderer Configuration

Configure the LineRenderer to:

  • Render the path's trajectory

  • Customize visual properties like width and color

  • Provide a clear visual representation of the potential agent movement

Unity automatically calculates the shortest path between two points. Add obstacles and modifiers to improve the pathing.

Check Unity documentation here for detailed explanations of navigation. Also, check out videos of Joshua Drewlow's detailed explanations on Unity + NavMesh for navigation

Last updated

Was this helpful?