Search Unity

Extract Vertices And Edges From Navmesh

Discussion in 'Navigation' started by Eduard6421, Apr 10, 2019.

  1. Eduard6421

    Eduard6421

    Joined:
    Oct 13, 2013
    Posts:
    4
    Is there any way to extract the vertices and edges of the baked NavMesh?
    I would like to implement my own path-finding algorithm while still making use of Unity's NavMesh System.
     
  2. Yandalf

    Yandalf

    Joined:
    Feb 11, 2014
    Posts:
    491
    Unfortunately no, the "mesh" you're seeing in the editor is only a representation of all the actual data the NavMesh system uses.
    Why do you want to roll your own Pathfinding?
     
  3. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    300
    This is also only partly true ;). You can extract the navmesh into a normal mesh.

    Code (CSharp):
    1. NavMeshTriangulation navmeshData = NavMesh.CalculateTriangulation();
    2. Mesh mesh = new Mesh();
    3. mesh.SetVertices(navmeshData.vertices.ToList());
    4. mesh.SetIndices(navmeshData.indices, MeshTopology.Triangles, 0);
     
    Last edited: Apr 12, 2019