Detect if RichAI is on Recast Graph

How can I detect that the RichAI is on a valid node in the Raycast Graph?
thanks

Hey,
You can use the AstarPath.active.GetNeares function.
https://arongranberg.com/astar/docs/navgraph.html#GetNearest
And check the distance to the agent.

Hi

The RichAI will always be on the recast graph. Every frame it is snapped to the closest point on the graph.

Also when isStopped=true ?

Yes. It will be clamped to the navmesh in that case as well.
The only requirement is that it needs to have a path. So in the beginning of the game when the agent’s destination is not yet set it will not do this. But once the first path has been calculated it will start doing it.

It’s not expensive if I have ~100 agents?

In some cases I don’t have a path… any other cheep way to detect this?

You could use

bool onTheGraph = AstarPath.active.recastGraph.PointOnNavmesh(agent.position, null) != null;

Works great!!!
Thanks

1 Like