AI jumps to "unreachable" nodes?

Dear :blush:

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.


(show connections is on, so there is no connection between this layers)

If i change “Max Nearest Node Distance” to 1, the problem still exists if the AI stands right next to the wall.

How to get a path only through linked nodes?

(the nodes are this way because the player can build stairs to make this nodes reachable)

Thanks again for your time! I am making great progress.
Have a nice day.

This is how it looks with a stair :blush:


(the reason for using a layered grid graph, are caves comming later)


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.

1 Like

Thank you for your time!

First about the stair graph picture:
I dont worry about how it looks. I am thinking its just a visual thing as you explained if i got it right.

Yes, my AI has a seeker. And a custom movement script with a callback OnPathComplete(Path path). If !path.error, i start iterating like this:

citizen.position = (Vector3)path.vectorPath[0];

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 :grinning: (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 :frowning:
Have a nice day!

Okay, I found something in the docs that exactly describes my problem. -> last topic “Reachability”. I need to do a
PathUtilities.IsPathPossible(node1, node2)
to get my desired behaviour :slight_smile: Very sorry for my blindness. I will test it tomorrow.

Have a nice day!

1 Like

Good morning!

Im nearly done. There is only one more strange thing i found and after hot fixing it, everything is working like a charm.

Im talking about the GetNearest() function. If i do:

NNInfo nnInfo= Vector3(10f, 5f, 10f));

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.

Now i added


to GetNearestNode() within LayeredGridGraph.cs.

Its working but feels dirty :expressionless:
Any words about this?

Thank you very much.
Have a nice day!


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);

while the original line uses something like

transform.Transform(new Vector3(x+0.5F, 0, z+0.5F));

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.

1 Like

Aron! Thank you so much! That makes sense.

Thank you so much! And sorry for my inability :roll_eyes:

Good feedback on asset store incomming.

Many greetings!

1 Like

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.