Accurate point reachable

The mouse can’t quite get close enough to his randomly selected destination

I check every frame if the point is reachable - in this case it is not reachable, but my code is returning that it is reachable. As a result the mouse doesn’t move. This is due to rounding caused by AstarPath.active.GetNearest()

One way to fix this is whenever I ask to move to a particular path, I move the endpoint to the result of AstarPath.active.GetNearest. However, that isn’t the best option because it means the AI would always be snapped and not able to move to exact locations.

Is there a better implementation I can use to determine if the destination of the current path is reachable?

Hi

It looks like you have the threshold already there in the code: QueryRadius*2.
The GetNearest call will return the closest point on the navmesh so the best way is, as you already do, to check if that point is close enough to the point you intended. You can check the magnitude only along the X and Z axes to avoid any differences along the y coordinate to affect anything. I suggest that you add the same check for the destination node.

You could set the destination to destinationNode.position (where you destinationNode variable is actually an NNInfo, not a node). The position field will be the closest point on the navmesh surface.