Jump to content

Pathfinding tools for Tiled


Sawyer
 Share

Recommended Posts

I've used Tiled to create my levels in Phaser.  I want to implement some AI Pathfinding.  

I've looked at EasyStar.js and seen it needs an array of which tiles are walkable.  

I have several layers and quite large maps so this would be a very long process to have to do manually.

Is there an easier way to do basic pathfinding with Tiled?

Link to comment
Share on other sites

I got Pathfinding.js working with Phaser. I just put it up on Github if you want to see it. You can see it here: https://github.com/JackolanternIR/onlinegameproofofconcept

I do wonder though about these layers on your maps. I am not sure what game you are making, but typically you will only need to run A* pathfinding on your collision layer, since they are the only thing in most cases that the player must move around. If you also, for example, have a PORTALS layer or something like that, if I remember right you could probably see how to add that to the array of tiles to avoid when pathfinding if you look at my code (inside the public/client/js/clientServices folder you will find the classes that deal with pathfinding). There is also a parent class called "MobileObject.js in public/client/js/classes/bases that deals with moving around the map using A*. Essentially it creates tweens to handle the array of movements. 

Hope this helps! 

 

EDIT: Oh, and here is the URL for Pathfinding.js: https://github.com/qiao/PathFinding.js  It really was a breeze to work with, and I felt it was much more flexible to use than EasyStar.js. 

Link to comment
Share on other sites

Thanks guys

I'll look in to pathfinding.js Jackolantern.

It's a team project and we have multiple collision layers (for several reasons).

I guess if needs be, I could add a new transparent collision layer over all of them to use for pathfinding

Link to comment
Share on other sites

I tried several Pathfinding scripts, and EasyStar was not "easy" to use, when you command a path and then have to change it during interaction, this woun't work as easy as first thought. I changed to pathdindings.js which is also writte above: https://qiao.github.io/PathFinding.js/visual/

It also was more quick. Size matters, on large maps the calculation went faster for above 0.3 seconds which is a lot. (measured only one calculation).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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