[BEHAVIOR] EasyStar.js pathfinding for tilemap

Post your completed addons to share with the community

Post » Mon Mar 14, 2016 4:18 am

Well to be fair, pathfinding is a cpu intensive operation. You have to keep it in mind when implementing it, and use it in such a way that actual pathfinding operations are done in an optimized way.
B
66
S
27
G
24
Posts: 968
Reputation: 18,546

Post » Wed Jun 29, 2016 9:42 am

All I get is this error when I try to pathfind between two sprite coordinates:

https://drive.google.com/file/d/0Bz86oQ ... sp=sharing
B
44
S
12
G
1
Posts: 231
Reputation: 3,875

Post » Wed Jun 29, 2016 5:08 pm

I'm sorry, but without more details on how the behavior was used, I won't be able help you much. The only wild guess I could make right now is that you would get this error if you added the behavior to a non-tilemap object.
B
66
S
27
G
24
Posts: 968
Reputation: 18,546

Post » Wed Jun 29, 2016 7:17 pm

Wait I'm supposed to apply it to the tilemap? I was under the impression the objects that use it to move need to have it. I guess I didn't look at your example closely enough.
B
44
S
12
G
1
Posts: 231
Reputation: 3,875

Post » Wed Jun 29, 2016 8:06 pm

Note that this is not a movement behavior per say, it's a pure pathfinding one. The movement can be done with another behavior, like moveTo from rexrainbow, or directly through events.
B
66
S
27
G
24
Posts: 968
Reputation: 18,546

Post » Tue Dec 27, 2016 2:36 pm

Magistross wrote:Hi ! I recently stumbled upon this neat little API for pathfinding and thought it would be cool to wrap it up inside a plugin/behavior for C2. I thought a behavior extending the official tilemap made the most sense for this so here goes :

live example (Drag and drop the blue/green square, and right-click to add/remove obstacle.)
example capx
behavior files

easystar demo done in C2 (need moveTo behavior)
live version

The behavior is rather straightforward, just hook it up to a tilemap, define walkables tiles with the appropriate actions and you're set. It uses a tag system so you can make multiple find path calls simultaneously, and EasyStar.js allows for asynchronous calculation if need be. Just try it out ! ;)

edit: corrected links, added another demo

New behavior files v1.01
v1.01 has an updated core (now using EasyStar 0.2.3, slightly modified to accommodate C2)
Key features are an optimized algorithm, possibility to add specific costs at tile coordinates, option to enable/disable corner cutting when moving diagonally

Does the example work properly with the updated files? Doesn't seem to draw the route properly?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Tue Dec 27, 2016 6:41 pm

Can anyone show me an example of how to make a character move to a tile using moveto? I've been studying the second example, and can't quite figure out how to simply make a sprite move through the nodes to a tile?

EDIT: Found one: pathfinding-bug-getting-out-of-an-area_p1029014?#p1029014

Is it possible to make a character move to the nearest walkable tile if you click on an unwalkable tile?

EDIT: got that one too! unwalkable-tiles-using-easystar-walk-to-nearest-tile_t185641
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Fri Dec 30, 2016 10:20 pm

@Magistross is there a way of smoothing nodes so the tiles dont cause a gridded/quantized motion? I think it's possible, if i'm not mistaken, using lerp?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Sun Feb 19, 2017 12:01 am

Hey, @Magistross, I'm absolutely loving this plugin! A problem I found, however, was that tiles were unable to be manipulated past a certain point in the layout. Maybe you could shed some light and give a little input on why this doesn't work? :?

https://www.dropbox.com/s/5se7tp187v9vj ... .capx?dl=0
B
24
S
7
G
1
Posts: 36
Reputation: 2,049

Post » Sun Feb 19, 2017 2:09 am

Oops! I needed to override the "setTileAt" function from the tilemap plugin so EasyStar could track changes made to the tiles. However I mixed up height and width somewhere along the way on the array "overflow" check. Once you reach a width greater than the height, it won't do anything (and vice versa).

Try redownloading the latest file, it should work now.
B
66
S
27
G
24
Posts: 968
Reputation: 18,546

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest