Jump to content

Easystar pathfinding path always empty


MeMyMo
 Share

Recommended Posts

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...