[BEHAVIOR] EasyStar.js pathfinding for tilemap

Post your completed addons to share with the community

Post » Fri Apr 17, 2015 4:27 pm

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

Behavior files v1.01
v1.01 has an updated core (now using EasyStar.js 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

**new** Behavior files v1.02
Yet another update to the core, now using EasyStar.js v0.4.1. Now featuring directional conditions and an even more optimized algorithm.
Last edited by Magistross on Fri Jun 09, 2017 1:58 pm, edited 12 times in total.
B
64
S
27
G
24
Posts: 959
Reputation: 18,478

Post » Fri Apr 17, 2015 6:12 pm

This looks like a really nice extension to tile map, thanks for your efforts…but all your links lead to the demo.
B
43
S
22
G
20
Posts: 735
Reputation: 11,977

Post » Fri Apr 17, 2015 6:22 pm

Thats not a bad idea, tilemap with efficient pathfinding.
Will try it out.
Image ImageImage
B
167
S
50
G
159
Posts: 8,168
Reputation: 102,932

Post » Fri Apr 17, 2015 7:34 pm

Bummer, I used the web version of Dropbox and it seems it didn't correctly "copy to clipboard" those links. I'll correct them immediately.
B
64
S
27
G
24
Posts: 959
Reputation: 18,478

Post » Fri Apr 17, 2015 9:03 pm

Wow, you have it running every tick, and its got no lag.
Image ImageImage
B
167
S
50
G
159
Posts: 8,168
Reputation: 102,932

Post » Mon Apr 20, 2015 1:52 pm

It's indeed pretty fast. At first I did the "every tick" part just as a quick way to test the plugin... but then I saw how it did not even lower the fps one bit, so I kept it !

However, it's still not a good idea to do pathfinding on an "every tick" event, mind you ! ;)
B
64
S
27
G
24
Posts: 959
Reputation: 18,478

Post » Mon Apr 20, 2015 4:08 pm

This is a really great behaviour, thanks again.
B
43
S
22
G
20
Posts: 735
Reputation: 11,977

Post » Mon Apr 20, 2015 4:13 pm

What is really amazing to me is that it ran so smooth on my phone. : D
ImageImageImageImage
B
59
S
19
G
51
Posts: 633
Reputation: 30,731

Post » Tue Apr 28, 2015 9:41 pm

Its breaking nw.js with minification.
Image ImageImage
B
167
S
50
G
159
Posts: 8,168
Reputation: 102,932

Post » Wed Apr 29, 2015 5:26 am

Thanks for sharing!
B
150
S
27
G
17
Posts: 909
Reputation: 32,323

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 1 guest