A* Pathfinding Project

RichAI pathing problems on Raycast graph update


#1

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?


#2

Hi

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


#3

Currently sitting on 4.2.7


#4

Hi

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?


#5

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.


#6

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.


#7

Hi

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


#8

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?


#9

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


#10

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.


#11

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.


#12

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?


#13

Nice!
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.


#14

I see.

Thank you Aron for helping solve this issue for me.