Sawyer Posted January 14, 2016 Share Posted January 14, 2016 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 More sharing options...
the user Posted January 14, 2016 Share Posted January 14, 2016 with layers it just becomes a pathfinding in 3d with x;y;z it's not that long to make it manually - it's just a simple pathfinder but with 6 ways outta each tile Link to comment Share on other sites More sharing options...
Jackolantern Posted January 15, 2016 Share Posted January 15, 2016 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 More sharing options...
Sawyer Posted January 16, 2016 Author Share Posted January 16, 2016 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 More sharing options...
s4m_ur4i Posted January 17, 2016 Share Posted January 17, 2016 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 More sharing options...
Recommended Posts