Path endpoint rounded off causes failure to reach destination

Using 4.1.12

Through manual testing in the editor, I’ve found that if I put my character’s path destination in the middle of one of the grid cells (I am using AIPath with LayeredGridGraph) the green line in the scene view will point at the target closely enough that he stops within endReachedDistance of the destination and everything is good.

Otherwise it seems to round off to the grid, as in this screenshot. The problem is that the character doesn’t stop within endReachedDistance of where I want him to go

This is not an issue if I use “Original” for End Point Snapping on Seeker. But the problem (as I wrote here Pathing through walls ) is that option ends up continuing to path through walls.

Is there a way to get the end point to be on the destination I want, without going through walls?

Hi

You may want to use the ClosestOnNode snapping mode instead of the Connection mode (which I believe you are using right now). You can take a look at the documentation for how the different modes work: https://arongranberg.com/astar/docs/startendmodifier.html#Exactness

I have the same problem with ClosestOnNode. What I need is something that will check if there is a path between the node and the destination and set the last point on the path to the destination if there is nothing blocking. I thought that Raycast Modifier would do this but I have that attached.

Huh, that looks odd. When using the ClosestOnNode snapping mode the endpoint of the path should lie exactly on the destination (blue circle). Do you think you could disable the modifiers and see if that changes anything.

Btw. I would recommend setting the start point snapping to ClosestOnNode as well, the NodeConnection mode doesn’t really make sense in a game that is not heavily grid based.

From the code it doesn’t look like ClosestOnNode will do that. All it does is returns the start or end point of the path.

case Exactness.ClosestOnNode:
	return start ? path.startPoint : path.endPoint;
  •   path.endPoint	"(149.9, 0.0, 331.0)"	UnityEngine.Vector3
    
  •   path.originalEndPoint	"(149.2, 0.0, 331.7)"	UnityEngine.Vector3
    

I disabled the modifiers without any improvement.

I didn’t look at that section of the code prior to this but it looks like Original with useGraphRaycasting should do what I want, since those flags would abort going through impassible areas.

Edit I tried Original with useGraphRaycasting and it worked for what I wanted.I’ll hold off on committing that change though because the comment in the inspector said ClosestOnNode should be faster.

Yes, but path.startPoint comes from a search of the closet node to a point, and it will be set to the closest point on that node for a grid graph.

Would it be possible for you to share your project with me so I could have a look, it might possibly be some combination of modifiers and other settings that breaks it for some reason (though I cannot figure out why it would)?

I don’t mind doing that but my project is pretty large. If you want to take this to a private conversation I can set you up with source control access. Or we can do screen sharing.

Sure. Could do a screen share first just to take a look at it. Just send me a PM.

Hey, just a final thing.
Do you think you could try out the latest 4.1.14 beta (https://www.arongranberg.com/astar/download), there is a fix there that might have something to do with it (see also ClosestPointOnNode is broken?).

The beta did not fix the problem.