From f8b3d722927954557f9c00e53dde004812c22131 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 Jul 2024 04:04:11 +0200 Subject: [PATCH] Fix bug with pathfinding when previous node is not null --- astar/Astar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/astar/Astar.cs b/astar/Astar.cs index 78a87f1..0ce55d1 100644 --- a/astar/Astar.cs +++ b/astar/Astar.cs @@ -92,7 +92,7 @@ namespace astar return PathFound(graph, neighborNode, currentNodeEnd, logger); float distance = (currentNodeStart.Distance??float.MaxValue) + (float)currentNodeStart.DistanceTo(neighborNode); - if (neighborNode.PreviousIsFromStart is null || neighborNode.Distance > distance && currentNodeEnd.PreviousNodeId != neighborId) + if (neighborNode.PreviousNodeId is null || neighborNode.Distance > distance) { neighborNode.PreviousNodeId = currentNodeEndId; neighborNode.Distance = distance;