Detect when NavMesh Obstacle Carve is done?

Hi everybody,

Working on a game that is turn-based but gridless. I’m relying on the NavMesh to path the character movement on their turn.

To do this, at the start of the turn, the unmoving characters all turn off their NavMeshAgent and turn on their NavMeshObstacle, and the “active” character (the one who’s turn it is becoming) turns off their NavMeshObstacle and turns on their NavMeshAgent.

However, the carve update on the obstacles seems to not be instantaneous. This results in the active character “jumps” because the area just below the character is still carved.

I’m trying to find a deterministic way to tell when it is “safe” to activate a NavMeshAgent once you turn off its NavMeshObstacle. Please help! (Thanks)

NavMesh contains an event called OnNavMeshPreUpdate which allows you to be notified that an update is about to start. You can likely assume that the frame after that will be updated. I have had no experience with it, so take that with a grain of salt.

That said, it is probably better to use masks. You would have an agent and an obstacle for each piece, and agents can go through “themselves” using masks.

It might also be interesting to not allow obstacles to carve the mesh. If you do not care much about advanced pathfinding, you can simply disable the carving, and allow all the pathfinding to happen on a local dumb level.