MeMyMo Posted April 2, 2017 Share Posted April 2, 2017 Hey, I'm messing around with pathfinding. Modified the Easystar Phaser plugin for ES6, but it seems to always return an empty path: https://max-arias.github.io/miner-idle-1click/ (source is 0,0) Calculation is here: https://github.com/max-arias/miner-idle-1click/blob/master/src/entities/Map.js ... let walkableTiles = [2, 150, 152, 166, 35, 68, 18] this.pathfinder = this.game.plugins.add(PathFinderPlugin); this.pathfinder.setGrid(this.layers[1].data, walkableTiles); } update () {} findPathTo(fromX, fromY, toX, toY) { this.pathfinder.setCallbackFunction((path) => { path = path || []; console.log(`path: ${path}`); // for(var i = 0, ilen = path.length; i < ilen; i++) { // map.putTile(46, path[i].x, path[i].y); // } }); console.log(this.layers[1].data); console.log(toX); console.log(toY); this.pathfinder.preparePathCalculation([0, 0], [toX, toY]); this.pathfinder.calculatePath(); } Grid data looks good... ideas? Link to comment Share on other sites More sharing options...
MeMyMo Posted April 4, 2017 Author Share Posted April 4, 2017 I'm an idiot, the walkable tile was 3, not 2. Link to comment Share on other sites More sharing options...
Recommended Posts