Using Unity’s NavMesh for Navigation with Area Targets

One of the applications which Area Targets support is navigation. As an advanced topic you can use Unity’s navigation system to detect and define walkable ground on your model and proceed to create static or dynamic navigation between the user and points of interest in your Area Target application.

Follow the steps to set up your mesh for navigation:

  1. Open your Unity Project that is properly setup with Vuforia Engine and your imported Area Target Unity package.
  2. Add the preview model of your scanned space as a mesh to your scene, ensure that the floor plan of the 3D mesh aligns with the horizontal (x-z) axis in Unity.
    1. Add a Mesh Renderer component if it does not yet possess one.
  3. Visit the guide on Building a NavMesh and follow the steps applying the changes described there to your scanned space until you reach the Adjusting the Bake settings.
  4. Depending on your scanned space, it is likely that adjustment of the baked agent size is necessary.
  5. Press Bake to see the NavMesh as a blue overlay on your scanned space. The blue overlay represents the walkable space and should appear as  one connected blue overlay.
    1. We have found that most doorways often are excluded in the NavMesh. To solve this, edit the Agent Radius to a smaller width. Similarly, step heights might also require adjustments 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.