Dynamic Navmesh cuts break RichAI

Hi,

I’m trying to make AI infantry to not collide with tanks. Infantry is moved by RichAI on Recast Graph. Tanks could be stationary or controlled by players.

So what I did is I put a NavmeshCut on tank, and found out that when you drag the cut under RichAI’s feet - it totally breakes. It starts to jitter and infinity move forward, never reaching the end.

This “broken” RichAI can be fixed by setting new target and recalculating path. I’m using RichAI.DistanceToNextWaypoint as a marker that movement is broken.

bool isError = Mathf.Approximately(richAI.DistanceToNextWaypoint, 0);
if (isError)
    State = PathState.Error;

But this approach comes with a downside - it forces to recalculate path infinitely while the Cut is moving. For example, if vehicle is passing by, AI will be stuck until vehicle drives away.

So, I don’t have any distinct question, but it would really help me if you could explain what is going on, and what possible solutions do I have

Asset version is 4.2.17

Hi

Are you setting the agent’s destination to (inf, inf, int) or clearing its path in some way?
I think the current RichAI script does indeed have a limitation that it cannot handle this case when a navmesh cut removes the ground below it. The RichAI needs a path to be able to navigate, and when a navmesh cut removes the nodes it was following, it will try to recalculate a new path automatically. However, if you have set its destination to (inf, inf, inf) then it will not be able to do this. I would recommend setting the destination to the agent’s own position instead. And in the meantime I’ll take a look and see if I can resolve this issue in a better way.

Actually, Destination field is kinda broken and it is always Infinity. But distance to target is correct, because it’s calculated using Endpoint field.

Inspector normal and debug while bot is running:

In case that matters I start path using
seeker.StartPath(transform.position, (Vector3)targetValue, OnPathCalculated);
And stop it using
richAI.SetPath(null);


In terms of what is going on original topic, I did not change destination at all. I just put whatever place on the map to go, move cut under agent and it lags out. Then if you put another (or same) target into seeker it’s gonna recalculate and fix itself