[BEHAVIOR] EasyStar.js pathfinding for tilemap

Post your completed addons to share with the community

Post » Mon Jul 03, 2017 8:51 am

Hello, in the example that you offer on the first page now the blue path does not appear.
This happens with the latest version 1.02
B
30
S
13
G
21
Posts: 838
Reputation: 14,656

Post » Mon Jul 03, 2017 2:38 pm

Move the "Node -> Destroy" action from line 2 down to line 3.

This example was created with a previous version of EasyStarJS. The asynchronous aspect of the plugin changed in a way that made the node sprite get destroyed AFTER they were created (in the same tick), so it was never visible. You could also only change the "asynchronous" property to "no", and the node sprites would appear again.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Post » Mon Jul 24, 2017 9:22 am

Is there possibility you add "Dijkstra's algorithm"?
B
5
S
1
Posts: 31
Reputation: 441

Post » Tue Jul 25, 2017 5:57 am

Unfortunately no. The whole plugin rely on the EasyStarJS library which is an A* pathfinding algorithm javascript implementation.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Post » Tue Sep 26, 2017 5:16 am

Hello!

Love this behavior! It simply works perfectly.

I am trying though to find the possibles moves on a grid like this :

Image

but it is very costy.. It takes like 1 second and a half on mobile, and like 0.3 seconds on pc, using the behavior.

I am looking for the paths in a loop from -unitMoveRange to unitMoveRange. Of course every tile has a different pathCost.

Any trick or advice on how to do it... better?
B
28
S
10
G
1
Posts: 24
Reputation: 2,266

Post » Wed Sep 27, 2017 3:22 pm

Using a breadth-first search might be more appropriate to find all possible moves, and then I guess you could use the pathfinding only once to go to the selected tile.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Post » Wed Sep 27, 2017 6:06 pm

Nice Plugin, fast.

The sample file is not showing the red path like in the live example.

Also, I noticed a bug when using the behavior on a tilemap object. If you want to change a tile on the right side, near the edge, it won't work. I.E., in the same sample file with the red path, if you reduce the size to match the screensize, and right click to change any tile it will not detect the event.
Image
B
108
S
24
G
18
Posts: 1,373
Reputation: 22,824

Post » Mon Oct 02, 2017 3:20 pm

Thanks @TELLES0808. It feels like I corrected this particular bug for the third time! That's what you get for copy pasting code instead of working with reusable code... :lol:

I finally updated the basic example to behave correcly with the newer version of the plugin (just had to configure the behavior to synchronous mode).

I also went ahead and added an expression to retrieve the cost from a tile coordinate and a condition to test whether or not a tile is walkable.

New version here.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Post » Thu Oct 12, 2017 6:14 pm

Bumping this topic for another new version.

I stumbled upon a nasty bug that made the plugin rebuild its array representation of the tilemap every tick instead of only on the first tick. This could have caused quite a bit of slowdown when working with large tilemaps.

Added a new condition : "Is tile walkable from". Basically the same as "Is tile walkable" but this one take into consideration directional conditions and thus need another coordinates pair. It will always return false if the two pairs of coordinates aren't neighbours.

Also removed the jQuery dependency by removing the jquery.map() call and using array.map() instead. All modern browsers should now support this.

New version here.
B
75
S
31
G
27
Posts: 1,000
Reputation: 20,735

Previous

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 4 guests