- A* version: [5.2.4]
- Unity version: [2022.3]
Previous behaviour of navmesh cuts: When scene is scanned or cached, the navmesh cuts would be ignored. The navmesh cut would apply when play mode started. Enable and disable the cut during runtime and the graph is updated fine.
New behaviour: If a navmesh cut is in scene and enabled, a scan or cache will completely remove it from the graph. So if you scan or cache with the cuts enabled, you can never turn them off in play mode. Cool new feature that you can turn cuts off and on in edit mode, but the problem is the same there.
Hi
If you cache a graph with a navmesh cut, it should not include the baked navmesh cut data.
I tried this just now:
- Add a navmesh cut to the scene
- Generate a cached graph
- Disable the navmesh cut
- Enter play mode
Result: the graph does not contain a cutout for the navmesh cut.
Are you seeing something different?
That works as you say, but the problem I have is:
- Add a navmesh cut to the scene.
- Generate a cached graph.
- ***Leave the navmesh cut enabled.
- Enter play mode. Disabling/enabling the navmesh cut does nothing. The cut is always there. Same behaviour in edit mode.
Example would be a closed door where the navmesh cut is already enabled when play mode starts, and later disabled to open the door.
I cannot replicate this. It works perfectly fine for me…
Can you replicate this in any of the example scenes?
I do some node cleanup in OnPostScan() and is causing the problem. The new feature where cuts work in edit mode results in my code not being able to find the nodes to keep (near the cut). Is there anything like OnPostScan(), except before the cuts are applied?
Everything on your end looks good, thanks.
Sorry. The cuts are now calculated as part of the scan.
What are you doing in OnPostScan that cannot have the post-cut navmesh?
You can access the pre-cut navmesh data using
NavmeshTile.preCutVertsInTileSpace
NavmeshTile.preCutTris
NavmeshTile.preCutTags
My OnPostScan() code uses markers to keep only the nodes that are required for each area. This make all my graphs much cleaner and allows me to select specific areas for each graph to keep. It removes my need for any tags and walkable/unwalkable. Similar in function to your RelevantGraphSurface, but no need to place them in each tile.
I think preCutTris is what I need. However, these always seem to be empty for me. Each tile.tris will have a bunch of triangles, but tile.preCutTris is always empty.
Nodes and tris length are as expected, but preCutTris is always 0. Not sure how I access these properly.
foreach (RecastGraph r in AstarPath.active.data.FindGraphsOfType(typeof(RecastGraph))) {
NavmeshTile[] testTiles = r.GetTiles();
foreach (NavmeshTile tile in testTiles) {
Debug.Log("nodes: " + tile.nodes.Length + ", tris: " + tile.tris.Length + ", precutTris: " + tile.preCutTris.Length);
}
}
They are only set if the tile is actually cut by a navmesh cut (check tile.isCut). Otherwise, the pre-cut data is identical to the post-cut data, and the pre-cut data is not saved, to reduce memory usage.
Hmm, I think that will make this tricky for me. I would need something like a tile.precutNodes to match up with the tile.precutTris.
I have tackled it from a different angle and seems to work ok. In OnPrescan(), I track and disable all navmesh cuts in scene. Then in OnPostScan(), I run my cleanup, then I re-enable the cuts.
That’s good enough for me at this point. Thanks as always for your help.