RichAI pathing problems on Raycast graph update

I have following setup:

  • RichAI controller
  • RaycastGraph (tiles)
  • NavMeshCuts for runtime graph updates

I noticed, that RichAI “looses” it’s pathing capabilities, when I update graph using NavMeshCut and it updates the triangle that is part of a path that the agent has not yet traversed.

Below should visualize the problem pretty clearly:

It looks like the path should be recalculated if the update happens to affected triangles. Shouldn’t it happen automatically?


The RichAI should indeed notice that its path has been invalidated and it should recalculate its path automatically immediately. Which version are you using?

Currently sitting on 4.2.7


I cannot replicate this issue locally. When moving around navmesh cuts the agents seem to recalculate their paths perfectly well.

Is canSearch disabled on your RichAI component?

canSearch is enabled.

If you are unable to reproduce it, it’s probably related to the way I’m using RichAI, my controller derives from it and adds just a few extras.

I’m looking into what may cause it.

Destination.x is Infinity and it stops the path recalculation, now the question is why it was set to infinity, when if had proper value initially.


The RichAI script never sets the destination property, so it must be something your code does.

Ok so what I got so far, it turns out AIBase.destination is always (Infinity,Infinity,Infinity), yet the RichAI is navigating just fine. Potentially using different target?

When the path should be recalculated, the destination is checked for Infinities, and it blocks the process.

Is it possible my setup somehow navigates without setting destination field?

That sounds strange because the end point of the path is always the destination property. Are you recalculating the path in some other way?

No, I dont :frowning: .

This is how I start the pathfinding for the agent:

isStopped = false;
canSearch = true;
canMove = true;
enableRotation = true;

endReachedDistance = stoppingDistance;

Seeker.StartPath(transform.position, targetDestination);

I enable/disable movement capabilities of an agent when entering/leaving buildings.

That is calculating the path in some other way :stuck_out_tongue:

If you are using one of the built-in movement scripts (such as RichAI) then you should be setting the ai.destination property instead. Optionally you can call ai.SearchPath when you want to force a recalculation to happen immediately, but usually you should leave that up to the automatic recalculation that the agent does itself.
Generally you would only call Seeker.StartPath if you are writing your own movement script.

Ok, setting the destination fixed it :smiley:

destination = targetDestination;

I guess it was misunderstanding on my side, it was hard to figure out this error, the pathfinding “worked” with my old approach.

Maybe Seeker component can handle this situation, when it notices the RichAI or other valid controller and just set the destination instead of seeking the path by its own.

Do I actually need the seeker component when I user RichAI?

Yeah. It’s just due to historical baggage that your previous approach works. I have kept it that way for backwards compatibility, but I would really like to prevent it.

You need the Seeker component because the RichAI component uses it. The RichAI component will call seeker.StartPath regularly to search for paths.

I see.

Thank you Aron for helping solve this issue for me.

1 Like