Force NavMeshCut disable to occur immediately

Broadly, what I am trying to do is have idle units cut around them, so that other units will path around them, instead of ramming into them.

Right now, I simply disable the NavMeshCut and enable the AI upon the start of movement. Unfortunately, the NavMeshCut takes an unknown amount of time to actually make the change, thus the AI jumps to the closest position on the graph, and that’s quite awkward, especially if it is a large unit.

I notice the ForceUpdate method on NavMeshCut, but it seems to only mark it as dirty. I then saw the ForceUpdate method on the navmeshUpdates instance, which appears to do the actual work. Alas, despite calling both, the change seems to happen too late, and the unit jumps.
image

In summary, I need a reliable way to determine if the cut change has occurred or not.

I ended up exposing the navMeshUpdates.lastUpdateTime, so I can only enable the AI after the nav mesh cuts have been applied. That seems to prevent the jumping. I’d like to hear @aron_granberg preferred answer to this issue though.

That being said, strangely, the units don’t seem to be pathing around the cuts. In fact, it appears that sometimes the cuts don’t impact all of the graphs. Any ideas about that?

Thanks!

Hi

Doing this will make sure the navmesh cut is updated on the graph immediately:

// Do some changes to the cut
cut.enabled = false;

// Schedule a graph update as soon as possible
AstarPath.active.navmeshUpdates.ForceUpdate();
// Immediatelly process all work items to make sure the navmesh is actually updated
AstarPath.active.FlushWorkItems();

See also the docs for ForceUpdate: https://arongranberg.com/astar/docs/navmeshupdates.html#ForceUpdate