Consider the following gif:
There are a lot of Gizmos, but the small magenta points are points in a pointgraph, and the long magenta capsules are points found via a path seeker. You’ll notice that when the start of the path (black spheres) is too close to a node, it is sometimes left out of the returned path.
I need to get ALL nodes in the path, regardless of how close it is to the start or end. What settings should I try to accomplish this? Is there a code solution if I am unable to do this via settings?
Hi
The path should contain all nodes in the path between the closest node to the start point and the closest node to the end point. Are you plotting path.vectorPath or path.path?
Hi Aron!
This is the code I am using for pathfinding:
// invoke the pathfinder
Path path = GetComponent<Seeker>().StartPath (
currentNode.Value,
currentNode.NextCircular().Value,
null,
GraphType.GetMask(GraphType.Edge)
);
AstarPath.WaitForPath(path);
if (!path.error) {
outlineBuffer.Add(currentNode.Value);
for (int j = 1; j < path.vectorPath.Count - 1; j++) {
outlineBuffer.Add(path.vectorPath[j]);
DebugExtension.DebugCapsule(path.vectorPath[j], path.vectorPath[j] + Vector3.up, Color.magenta, 0.0825f, 0, false);
}
} else {
Debug.Log(path.errorLog);
outlineError = true;
}
however, now that I look at it…I am wondering if I misunderstood the path. I start at index 1 because I had assumed the path already contained the start point, but maybe I am wrong?
I just tried to change the start index to 0, but that did not work; it just double included my requested start point. What am I doing wrong?
Hi
How the start and end points will be added or modified depends on the settings in Seeker -> Start End Modifier.
For your use case I think you want “add points”=false and startPoint=endPoint=“SnapToNode”. Then you can start from index 0 and loop up to the last index as well.
That didn’t really solve the problem unfortunately:
notice that black wire sphere, that is a node that was ignored during pathfinding. The green cylinders represent both points added outside of pathfinding, and points added via pathfidning. The black spheres are actually the results of NavGraph.GetNearest(). That node in particular should have been part of the path though.
And your loop looks like this now, right?
for (int j = 0; j < path.vectorPath.Count; j++) {
Hah! I forgot to fix the count check. that fixes the problem, but it now introduces a new one. Now the path is overzealous, and includes nodes just beyond the start and/or end points.
When I change the exact start/end point modifiers to “Original”, that problem goes away, but then I am back to square one (even with the fix of that for loop bug). I simply want every single node along the path that is between start and end points. What else can I try?
Hi
Are the start and end points exactly on a node or can they be between nodes?
They can be between nodes, but also in top of it. they are set via a raycast (capsulecast actually).
I tried the “Node Connection” option on the seeker, and the problem appears to go away, but this option isn’t even documented. Can you explain what it does?
Hi
Yes, I was going to suggest using the Node Connection mode. However note that the last point of the path may not be ON a node in that case.
I thought the NodeConnection mode would be documented in the current releaed version… but maybe it was not.
Recently I have made some changed to the NodeConnection mode to make it work better in a few situations.
The documentation in my dev version is
/** The point is set to the closest point on one of the connections from the start/end node */
Since the closest point to the end point on a connection from the end node will always be slightly further along the path than you really wanted to go, you can simply skip the last vertex of the path (and the first one).
ah hah! this appears to work! All I needed to do in addition was to ignore the last point in the path. The first one seems fine though. hopefully this solves all the issues I had. I’l bug ya again if it doens’t 
Thanks!