PathFinding.js
PathFinding.js copied to clipboard
Example not working
The first example in the documentation with walkability matrix does not seem to work. var walkabilityMatrix = [[0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0], [0, 1, 1, 1, 1], [0, 0, 0, 0, 0], [1, 1, 1, 1, 0], [0, 0, 0, 0, 0]];
var grid = new PF.Grid(walkabilityMatrix); // typo here in the original documentation - matrix instead of walkabilityMatric var finder = new PF.AStarFinder(); var path = finder.findPath(0, 0, 4, 6, grid);
Produces the following error: TypeError: this.nodes[e] is undefined
I'd say this is a duplicate of #132.
I guess you just downloaded the pathfinding-browser.min.js and/or you run your code in the visual demo .
That version of Pathfinding.js is outdated, it does not detect the Grid width/height automatically. The documentation is for the latest version that you can build yourself using npm.