From ebd0ee6ccffeb4078aa2856eb688c20b5f000fb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20V=C3=B6gele?= Date: Wed, 2 Mar 2022 22:32:27 +0100 Subject: [PATCH] Fix the order of colission checks during pathfinding waypoint culling to make one-way-walls work properly --- js/pathfinding.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/pathfinding.js b/js/pathfinding.js index d361c93..e1b76da 100644 --- a/js/pathfinding.js +++ b/js/pathfinding.js @@ -44,7 +44,7 @@ export function findPath(from, to, token, previousWaypoints) { let currentNode = lastNode; while (currentNode) { // 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 path[path.length - 1] = {x: currentNode.node.x, y: currentNode.node.y}; else