Using Unity’s NavMesh for Navigation with Area Targets

One of the applications which Area Targets support is navigation. You can use Unity’s navigation system to detect and define walkable ground on your model or point cloud and proceed to create static or dynamic navigation between the user and points of interest (POI) in your Area Target application.

Follow these steps to set up your mesh for navigation:

  1. Open your Unity Project and set it up with Vuforia Engine and your imported Area Target Unity package.

Your imported Area Target will either appear as a textured mesh or a point cloud. But the steps are the same.

  1. Add the prefab model as a child to your AreaTarget GameObject from the Assets/Editor/Vuforia/YourDataSetName/ folder.
    1. It will either be named PreviewModel.prefab for meshes.
    2. Or NavMesh.prefab for point clouds.
  2. Ensure that the floor plan of the prefab aligns with the AreaTarget GameObject.
  3. Select the AreaTarget GameObject and set the Static to Navigation Static. Select Yes, change children.

  1. Go to Window -> AI -> Navigation, and in the tab Bake, press Bake.

A blue overlay should appear that represents the walkable space as one connected surface. Visit the guide on Building a NavMesh to learn how Unity’s NavMesh is created.

  • Depending on your scanned space, it is likely that adjustments of the baked agent size are necessary. Adjust the baked agent size and Press Bake again to update the NavMesh on your scanned space.
  • If there are still gaps between the overlay around doorways, then edit the step heights to include more walkable areas in your scanned space. Proceed to press Bake again for an updated overlay.

Customizing the NavMesh

You can now author a calculated path between two points by creating destination points. As Unity calculates the shortest path between the two points, you may want to set up Navigation Areas and Costs which can help improve pathing as shown in the images below. Visit Unity’s article to learn more on setting up Not Walkable or higher cost areas.

You can create new classifications for areas under the Navigation Window in the Areas tab. Use a 3D Cube GameObject or other mesh to mark the areas, you wish to classify as a higher cost.

  1. Place a GameObject or mesh in your scene at a location you wish to mark as Not Walkable.
  2. In the navigation window under Object, enable Navigation Static and classify your GameObject under the Navigation Area dropdown menu as a higher cost navigation area or Not Walkable.
  3. Select the Navigation window and the bake tab and rebuild the NavMesh by pressing Bake. You may deactivate the GameObject afterwards.  

The NavMesh is now set up and you may continue to edit the NavMesh for your needs or start adding agents to your scene and make them guide, patrol and move between points. Or, you can set up navigation between the user and points of interest at runtime. Use NavMesh obstacles to create blockades or restrictions to navigation at runtime. Return to Unity’s manual to learn more about the NavMesh.