From 8d243ce9192e574abd0b6e20a8a27ce00a3481d4 Mon Sep 17 00:00:00 2001 From: Jonathan Calvert <38069151+JDCalvert@users.noreply.github.com> Date: Mon, 28 Feb 2022 18:13:12 +0000 Subject: [PATCH] Fix one-way wall collision detection (fixes #167) (#172) --- js/pathfinding.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/pathfinding.js b/js/pathfinding.js index 2ff80a6..87a384d 100644 --- a/js/pathfinding.js +++ b/js/pathfinding.js @@ -42,7 +42,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(currentNode.node, path[path.length - 2], token)) + if (path.length >= 2 && !stepCollidesWithWall(path[path.length - 2], currentNode.node, 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 @@ -74,7 +74,7 @@ function getNode(pos, token, initialize=true) { } // TODO Work with pixels instead of grid locations - if (!stepCollidesWithWall(pos, neighborPos, token)) { + if (!stepCollidesWithWall(neighborPos, pos, token)) { const isDiagonal = node.x !== neighborPos.x && node.y !== neighborPos.y && canvas.grid.type === CONST.GRID_TYPES.SQUARE; let targetLayer = pos.layer; if (use5105 && isDiagonal)