Jump to content

Pathfinding in TileMap


Recommended Posts

Hi guys!


I'm testing phaser for a small game that i'm doing.


I noticed that there is no pathfinding implemented in phaser.


Which libraries are you using for this?


I've used "Pathfinding.js" in the past, but it requires a matrix grid. The data property in the tilemaps of phaser are stored in a single array, instead of a matrix.

So using this library requires me to keep replicating the changes in the tilemap data property into a matrix.


How can achieve this more easily?


Link to comment
Share on other sites

Why would you need to replicate?

Your pathfinding algorithm can work just as well with the array, since you still have map boundaries (width and height).


Just calculate the array index of a certain field x/y, then pull that value from the array to analyze it in your A* algorithm.

Link to comment
Share on other sites

My bad, i didn't know that the TileMap had the map data property... 



This is the code... I don't know why but isn't working in plunkr:



Thanks for the help!


BTW, is there any documentation or anything? I'm using console.log and the sources to see the features.. (besides the example page)

Link to comment
Share on other sites

Sorry I've no idea why it doesn't work on plunkr, maybe something to do with the paths to the files?


Documentation is coming I promise! I'm working my butt off ready for the 1.0 release on Monday, and it has docs. Hopefully will get time to do some mini getting started guides too.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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