I have an issue with the “Max Nearest Node Distance” setting.
The .gif shows how an AI jumps to a node at the end of the path that should not be accessible from its position. There is also a picture of the graph. The desired behavior is that the AI should not get a valid path to the selected location.
How are you calculating that path?
If you are using the Seeker component I would recommend setting the Seeker -> Start End Modifier -> End Point setting to SnapToNode instead of Original (which is what I guess you have set it to).
That is a curious case in which it (in general) is not possible to render a continuous mesh. Consider the case of a spiral staircase 2 nodes wide and deep, but many nodes high. It’s a bit complicated to explain, but in the middle of that staircase you would get many vertices which need to be both separate and at the same position and it creates all kinds of issues.
I’ve tried your suggestion with End Point Snapping -> Node Center (Snap To Node).
Starting Point Snapping -> Original. But it doesn’t fix the problem. In some cases he still gets a path. And in some cases he now stops at the wall, but he should not get a path at all if the path isn’t complete.
.gif (grid is the same as in my first post, no connection between layers)
If you look closely you can see sometimes the end point is not where i clicked too
Have a nice day!
Okay, I found something in the docs that exactly describes my problem.
https://arongranberg.com/astar/docs/usingnodes.html -> last topic “Reachability”. I need to do a PathUtilities.IsPathPossible(node1, node2)
to get my desired behaviour Very sorry for my blindness. I will test it tomorrow.
I would expect it prints (10.0, 5.0, 10.0), because there is the nearest node. But it prints (9.0, 5.0, 9.0). Together with the missing IsPathPossible() that caused all the problems i got.
That’s possibly something that could be caused if your earlier edits to the SampleCell method.
I do in particular note that you have a line which looks like
nodes[nodeCount].position = new Vector3(x, y + 1f, z);
The grid graph assumes that the nodes are laid out in graph space with the first node at (0.5, 0.5) the second node at (1.5, 0.5) etc, and then transformed to world space using the transform field. That same transform is then also used in the GetNearest method to convert a world space position to graph space so it can more easily find the closest node.
Also. About the reachability. The default behavior of the system is to find the closest node that the agent can reach, and then move the agent there. So if you try to move the agent to a point it cannot reach, it will try to get as close as possible. It’s hard to say why your agent teleports to the end point of the path without knowing more about how your movement script looks though.