Agents paused while rebuild recast?

Hi,

It looks like any agents within a tile that is being rebuilt for the recast graph has it’s nav paused until the area is rebuilt. I have a reasonably small tile size and so this only happens if you’re painting under or very near a player.

I’d like to understand:

  1. What decides when the agents are paused? Is my description above accurate?
  2. How can i find out when they are paused for this reason? Is it the stopped property or something else?
  3. Is there any way of this being avoided altogether? My players will notice if agents stop when altering terrain near them.

Thanks,

Hi

Yes, when graphs are being updated, all pathfinding is paused. They shouldn’t stop though, they should only not be able to calculate any new paths during this time. They should continue following their current paths as best they can.

Ok so this is definitely happening. Using the Debug info the only thing that changes when I alter the nav near a player is that their Path Pending becomes true while editing and the false after i’ve stopped editing.

It looks like the issue might be this RichAI / AIPath behaviour on RecastGraph update.

Debugging the package now so posting my findings. Even with RichAI set to never automatically recalculate paths it still pauses as soon as i paint so it’s not the next path calculation being blocked.

Ok yeah it’s as you say. RichPath is being told that some nodes have been destroyed and that the path needs to be recalculated immediately.

Is there any way around this at all? It’s pretty much a shipstopper for my game. For me a primary solution is that the ai carries on walking while editing and a secondary solution is that i do something game related like stop them walking in this scenario and make them wait for the terrain to be updated.

Is it possible to cache the node positions for RichAI (or a custom AI) for the path so that when the nodes are invalidated it carries on following the positions. Once a new path is calculated we cache the positions again?

Thanks,

So i think the best solution is to know that a path has become invalid due to one or more nodes being destroyed. Do i have access to this information?

The code im debugging is in the package cache, we don’t have the source checked in anywhere.

So i shoehorned a callback into RichAI
RichAIPathDestroyedCallback.txt (1.4 KB)

This seems to do what i want but im sure you’ll point out the flaw in it.

Thanks,

Hi

Hmm. Are you continuously recalculating the graph over a long duration, or are you just making a single update?

Hi,

It’s height editing over a non-trivial period of time, usually a few seconds i would say.

Aha. Is it possible for you to do the edits in a batched manner (e.g. update only once every second) or wait until the whole edit is done and then update the graph?

I don’t think so, that would means either:

  • The user would be painting and nothing updates until theys top
  • The user would be painting and the terrain would visibly change but the nav mesh not leading to players walking through the terraina and obstacles.

Maybe there is some trick im missing. I can’t imagine that this has never been done before :).

Updating once every second should surely be enough if the agents don’t move very quickly?

Actually you’re probably right. Thinking about it the sort of errors you would notice are only going to be where the player might make the slope too steep to walk on and so they are temporarily navigating on a surface they shouldn’t.

That’s not the end of the world, i’ll give it a go.

Ok so i’ve tried this and it’s 99% fine. If i was being really picky i’d say there is occasionally a very small
stutter in the RichAI near the paint area but it’s very hard to notice.

Thanks,

1 Like