Phaser Pathfinding Help

Recommended Posts

Contrary to the name, I am finding Easystar.js to be intensely not-easy.

I have created a tilemap in Tiled with: base, collision, and foreground layers. The collision layer consists of two tiles, a walkable (6669) and a non-walkable(540). I have set up easystar in my create and update loop as described in the docs (see below) but constantly get either "The path to the destination point was not found", or "Your start or end point is outside the scope of your grid.".

current code:

var level = map.layers[1].data;

easystar =newEasyStar.js();

easystar.setGrid(level);

easystar.setAcceptableTiles([6669]);

easystar.enableDiagonals();

easystar.enableCornerCutting();

easystar.findPath(player.x, player.y, 0, 0, function (path) {

console.log("HERE")

if (path ===null) {

console.log("The path to the destination point was not found.");

} else {

for (var i =0; i < path.length; i++) {

console.log("P: "+ i +", X: "+ path.x +",Y: "+ path.y);

}

}

});

I have looked at just about every example, dissected every bit of code I can, and read every doc I can find on the subject matter but cant seem to make any headway.