Search Unity

How does NavMesh system determine which horizontal surfaces to include?

Discussion in 'Navigation' started by trzy, Jun 19, 2017.

  1. trzy

    trzy

    Joined:
    Jul 2, 2016
    Posts:
    128
    Hi,

    I'm building nav meshes using the scripting API (needs to be done this way on HoloLens because the spatial meshes are not available until the user scans his/her room). It's unclear to me which surfaces the NavMesh selects. The default rotation for NavMesh data is Quaternion.identity and I know it uses the up vector but given a mesh with lots of raised platforms, as in the image below, how does it determine what to include and exclude?

    For example, the picture here shows a captured scan of my room. You can see the NavMesh system has processed the floor. But why not instead the bed, for example?

    Also, is it possible to have completely discontinuous regions? I would be quite happy to have raised platforms (e.g., the bed or the couch in this image) constitute NavMesh surfaces of their own with no links to the floor. Agents placed on the bed would be confined to the bed, etc.

    The way I presently build my NavMesh is to include all meshes and a gigantic bounding box that is guaranteed to enclose them all (where the origin at Vector3.zero is chosen arbitrarily by the HoloLens).

    Thank you!

    Bart navmesh.jpg
     
  2. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
  3. trzy

    trzy

    Joined:
    Jul 2, 2016
    Posts:
    128
    Thank you for the reply! I thought I had followed up but I guess my post got swallowed. It turns out the problem was the height of my nav mesh agent! It was very large, and I guess the voxelization is proportional the agent dimensions.

    By the way, how can multiple nav mesh agent settings be defined in the scripting API? Given n input meshes and k agent types, is the idea to generate k NavMeshData objects by using UpdateNavMeshData() multiple times, once for each agent type?
     
  4. Jakob_Unity

    Jakob_Unity

    Joined:
    Dec 25, 2011
    Posts:
    269
    correct – each agent type can only 'see' navmesh built for its own type.

    In the editor you can use the 'Agents' tab to add/remove/modify agent settings.
    At runtime you can create and use navmesh settings for building as you please - the important bit is that the agentTypeID that you build for must match that of the agent.