Search Unity

How to get data for holes in navmesh

Discussion in 'Navigation' started by jdtec, Nov 16, 2019.

  1. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    97
    Is there a way to get the vertices/edges that make up a hole in a navmesh? For example, the white poly in this image?

    Screenshot 2019-11-16 at 07.28.23.png
     
  2. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    164
    Not sure what you are trying to achieve, the only way I know to get hold of the mesh is to do this:

    Code (CSharp):
    1.  
    2. NavMeshTriangulation navmeshData = NavMesh.CalculateTriangulation();
    3. Mesh mesh = new Mesh();
    4. mesh.SetVertices(navmeshData.vertices.ToList());
    5. mesh.SetIndices(navmeshData.indices, MeshTopology.Triangles, 0);
    6.  
    Then run a hole detection algorithm against this mesh. Unfortunately you cannot change the mesh and assign it back to the NavMesh, if that is what you wanted to achieve.
     
    jdtec likes this.