Unable to align GameObjects when apply the navmesh stored using Navmesh Prefab.

Hi Aaron,

As the title,In order to reduce the time spent scanning the entire large map using RecastGraph(plus I also use multiple RecastGraphs for different agent types), I tried to study the NavmeshPrefab of the Beta version to create navmesh, but whenever I import the .bytes data made by NavmeshPrefab , Navmesh always cannot accurately align the gameObjects.

After reading the documentation, I think it may be because Navmesh will be mainly aligned with tiles when call Apply(). Is there any way to make Navmesh align to the position of the gameObjects instead of aligning the gameObjects to Navmesh?

As a side note,
Because the map I am currently making is a design similar to 3d version of 「enter to gungeon」 , the room is randomly selected and placed on the map before the road connecting room is generated. Therefore, the position of the room is fixed at the beginning, so The 「Snap to closest tile alignment」function does not meet the effect I want.

Thanks in advance,

Hi

NavmeshPrefabs must be aligned to the tiles in the navmesh. That’s core to how they work and are able to efficiently update the navmesh. So you must make sure that your prefabs are spawned on a fixed grid.

Your map doesn’t look particularly big, though. Are you sure you can’t just scan the whole map when it loads? Especially when using the beta, that shouldn’t take long.

Aaron, Thanks for your reply,
I understand the part about 「aligned to the tiles」 is the core.

Because it is still in the research stage, the screenshot attached above is the scene simulated by moving the problem to a new project, not the real map of the main project, so the map looks relatively small.

The map of the main project is to scan the whole map to make navmesh, but because it needs to scan for 5~6 seconds every time you enter the map, so I started to study PrefabNavmesh.

According to the reply, it seems that the scanning speed of the Beta version will be faster than release version, right?

Thanks in advance。 :slightly_smiling_face:

Yes. Scanning in the beta version is faster than the release version.

Note that you can also set

recastGraph.scanEmptyGraph = true;

and then use AstarPath.active.UpdateGraphs(bounding box) to calculate only the regions of the world that are relevant to you, on the fly.

Setting scanEmptyGraph before the graph is scanned, will make the graph only add empty tiles to the graph once it is scanned. This is very fast. Then your graph updates can fill in the real data when you need it.