What is the offset of external NavMesh?

I wrote script to create NavMesh from Unity native and got data of vertices and triangles in world space.

					for (int i = 0; i < tris.Length; i++) tris[i] = unityTriangles[i];
					for (int i = 0; i < verts.Length; i++) verts[i] = new Int3(unityVertices[i]);
					recast.ReplaceTile(x, z, 1, 1, verts, tris);

I checked the workflow of BuildTileMesh and DeserializeGraphExtraInfo and managed to import it.
However, there seems to be an offset. How to fix this?

image

Hi

The ReplaceTile method takes vertices in ‘graph space’. Quoting the documentation for that method:

The vertices are assumed to be in ‘tile space’, that is being in a rectangle with
one corner at the origin and one at (#TileWorldSizeX, 0, #TileWorldSizeZ).

One easier option to import a Unity navmesh might be to convert it to a Mesh object and then use a NavmeshGraph. This will however discard the tiling info.

That is not good for me as I expect to reloading NavMesh at runtime.
I will call unity API to scan (as it is faster and generates more fitting-surface NavMesh) and use A* to perform pathfinding.

I know how to fix it now. I just subtract bound min and former tile count. :slight_smile: