Fix the order of colission checks during pathfinding waypoint culling to make one-way-walls work properly
This commit is contained in:
+1
-1
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user