[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
33
S
13
G
22
Posts: 847
Reputation: 14,826

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
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

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
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

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
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

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
109
S
24
G
18
Posts: 1,385
Reputation: 22,903

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
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

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
80
S
33
G
27
Posts: 1,027
Reputation: 21,114

Post » Sat Feb 10, 2018 4:05 pm

@Magistross I don't suppose there's a way to have the tilemap's collision polygon block the path? My tilemap is mainly walkable, but has walls to the side. At the moment, the objects will happily walk through walls, which I'm trying to avoid.

Is this only useful for entire tiles being walkable or unwalkable? No way to default all tiles to walkable and collision polys to unwalkable?
B
93
S
18
G
8
Posts: 1,026
Reputation: 12,353

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests