Fix the order of colission checks during pathfinding waypoint culling to make one-way-walls work properly

This commit is contained in:
Manuel Vögele
2022-03-02 22:32:27 +01:00
parent 1d477094b8
commit ebd0ee6ccf
+1 -1
View File
@@ -44,7 +44,7 @@ export function findPath(from, to, token, previousWaypoints) {
let currentNode = lastNode; let currentNode = lastNode;
while (currentNode) { while (currentNode) {
// TODO Check if the distance doesn't change // TODO Check if the distance doesn't change
if (path.length >= 2 && !stepCollidesWithWall(path[path.length - 2], currentNode.node, token)) if (path.length >= 2 && !stepCollidesWithWall(currentNode.node, path[path.length - 2], token)) {
// Replace last waypoint if the current waypoint leads to a valid path // Replace last waypoint if the current waypoint leads to a valid path
path[path.length - 1] = {x: currentNode.node.x, y: currentNode.node.y}; path[path.length - 1] = {x: currentNode.node.x, y: currentNode.node.y};
else else