casarock Posted November 25, 2013 Share Posted November 25, 2013 Hi, I've created a plugin for phaser which adds a wrapper for Easystar.js (https://github.com/prettymuchbryce/easystarjs). I guess there is room for improvements, but it works! You could find it here: https://github.com/appsbu-de/phaser_plugin_pathfinding. feel free to use and improve it! Cheers! Mike, tametick, shawnbless and 3 others 6 Link to comment Share on other sites More sharing options...
rich Posted November 25, 2013 Share Posted November 25, 2013 Awesome!! I actually had this on my "to do" list for next week, so I'm stoked that someone else did it Will take a good look shortly. shawnbless 1 Link to comment Share on other sites More sharing options...
shawnbless Posted November 26, 2013 Share Posted November 26, 2013 casarock! Really nice job man! I too was looking to use this and you have made it easy! Thanks! Link to comment Share on other sites More sharing options...
Alvin Posted December 2, 2013 Share Posted December 2, 2013 I just used it and this is really good, well done. Link to comment Share on other sites More sharing options...
shawnbless Posted December 2, 2013 Share Posted December 2, 2013 I too have used it in my game and agree, it is really good. Thank you casarock! Link to comment Share on other sites More sharing options...
PrettyMuchBryce Posted January 11, 2014 Share Posted January 11, 2014 Thanks casarock. I have included a link to your project in the README.md for easystar. Link to comment Share on other sites More sharing options...
xronn Posted March 12, 2014 Share Posted March 12, 2014 Has anyone got an example of this working? I can't even seem to get the demo to do anything for v1.1.3 AndreasWienes 1 Link to comment Share on other sites More sharing options...
marvster Posted May 17, 2014 Share Posted May 17, 2014 I've set up a test and everything seems to work fine. But I just can't figure out, how to publish the path in the callback to other objects.The path for example should be attached to the player, as the object will listen if path-information will be available and track along.I don't want to use asynchronity, as the screen is small enough and if it's not done within 1000 iteration, the move will be void. My tries so far:[..]findPath: function() { pathfinder.setCallbackFunction(function(path) { path = path || []; this.pathfinder.resultSet = path; this.pathfinder.isReady = true; }); this.pathfinder.preparePathCalculation(this.getPlayerTile(), this.getInputTile()); this.pathfinder.calculatePath(); //console.log(this.pathfinder.resultSet); },update: function () { if (this.pathfinder.isReady) { console.log('calculation is ready'); this.player.path = this.pathfinder.resultSet; this.pathfinder.isReady = false; } [..] }[..]'use strict';var TempPath = {isReady: false, resultRest: []};[..]function TestPathFinder() { };TestPathFinder.prototype = {[..]findPath: function() { pathfinder.setCallbackFunction(function(path) { path = path || []; TempPath.resultSet = path; TempPath.isReady = true; }); this.pathfinder.preparePathCalculation(this.getPlayerTile(), this.getInputTile()); this.pathfinder.calculatePath(); } update: function () { if (TempPath.isReady) { console.log('calculation is ready'); this.player.path = TempPath.resultSet; TempPath.isReady = false; }[..] }};Everything is set up fine as following callback will give results:pathfinder.setCallbackFunction(function(path) { path = path || []; console.log(path); });How can I solve it? I'm finally so near to a practical solution.. :/ Link to comment Share on other sites More sharing options...
marvster Posted May 19, 2014 Share Posted May 19, 2014 Found the solution:pathfinder.setCallbackFunction(function(path) { path = path || []; TempPath.resultSet = Object.create(path); TempPath.isReady = true; });I needed to clone the result, not just set a reference to it.Anyway. Is there any planned efforts for a phaser inbuilt path finder? Maybe with a choice of a* or jps? Link to comment Share on other sites More sharing options...
ForgeableSum Posted January 2, 2015 Share Posted January 2, 2015 How might one use this plugin to set sprites as walkable and non-walkable? From what I understand, the plugin only works with tiles. I have a need to find the quickest path around sprites. Any ideas? Link to comment Share on other sites More sharing options...
ForgeableSum Posted January 2, 2015 Share Posted January 2, 2015 After thinking about it for a while I've decided the best course of action would be to dynamically generate a grid A* could interpret which represents where all the sprites are. Squares on the grid would need to be at least the size of the smallest sprite (preferably half the size) and when sprites are moved, the grid would update. I'm pretty sure this is the easiest way to achieve pathfinding with sprites being walkable/non-walkable instead of tiles. My concern is that the grid squares will have to be extremely small, like 5 x 5 and that's a lot of squares on a map that is 3k x 3k... wouldn't generating and dynamically updating such a grid suck up a lot of memory? Does anyone have any comments/suggestions? Link to comment Share on other sites More sharing options...
CtlAltDel Posted January 2, 2015 Share Posted January 2, 2015 this link might be of use to you: http://www.david-gouveia.com/portfolio/pathfinding-on-a-2d-polygonal-map/ Good luck! ForgeableSum 1 Link to comment Share on other sites More sharing options...
s4m_ur4i Posted December 16, 2015 Share Posted December 16, 2015 This post is a bit older but maybe someone is still serious, I use the latest easystar, and everything works fine but:you can not update your grid. Easystar will output no path if you re-run the "setGrid" function..Seems like this is common behavior? Any solutions?If you run a "building" game, or some kind of strategic game, the pathfinding is useless without refreshing the grid.kind regards Link to comment Share on other sites More sharing options...
ForgeableSum Posted December 18, 2015 Share Posted December 18, 2015 This post is a bit older but maybe someone is still serious, I use the latest easystar, and everything works fine but:you can not update your grid. Easystar will output no path if you re-run the "setGrid" function..Seems like this is common behavior? Any solutions?If you run a "building" game, or some kind of strategic game, the pathfinding is useless without refreshing the grid.kind regards In my implementation, the grid gets thrown out every time you use it. So you need to use a copy of the grid rather than the grid itself to find a path. I'm pretty sure this is common behavior on most a* implementations. Link to comment Share on other sites More sharing options...
s4m_ur4i Posted December 29, 2015 Share Posted December 29, 2015 In my implementation, the grid gets thrown out every time you use it. So you need to use a copy of the grid rather than the grid itself to find a path. I'm pretty sure this is common behavior on most a* implementations. thanks! solved. Link to comment Share on other sites More sharing options...
Recommended Posts