-
Notifications
You must be signed in to change notification settings - Fork 252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Find path to direct neighbour #7
Comments
There is a bug in the code, as pointed out by user DMGregory on Gamedev.Stackexchange: In file Node.cs,
should be
Fixing this bug in the code could get the rest of the code to work, so the solution you propose might not be needed. |
thx. |
Complementing the suggested topic optimization, add the commented line after the while loop: // In Pathfinding.cs:
Vector3[] RetracePath(Node startNode, Node endNode) {
List<Node> path = new List<Node>();
Node currentNode = endNode;
while (currentNode != startNode) {
path.Add(currentNode);
currentNode = currentNode.parent;
}
path.Add(currentNode); // Be sure to add this line, or the nearest neighbour will be skipped;
Vector3[] waypoints = SimplifyPath(path);
Array.Reverse(waypoints);
grid.path = path;
return waypoints;
} |
It could be that you left this out for optimisation reasons, seeing as you could easily implement a way to check if one of the neighbours is your target tile before even calling the regular algorithm,
But the algorithms implementation (at least after episode 5) cannot find the path to it's direct neighbour.
Here's a proposed fix:
The text was updated successfully, but these errors were encountered: