[BEHAVIOR] EasyStar.js pathfinding for tilemap

Post your completed addons to share with the community

Post » Wed Oct 07, 2015 12:59 pm

so im tinkering around with this plugin some days now, its really awesome and easy to use and the performance is so great that i came away with some ugly logic but now is the time where i came to a deadend with my ugly logic :D

my idea was to ad the positions of characters on the tilemap as additional obstacles, remove them when they change theyre position and add the new position as an obstacle. I couldnt find a way to check for this event efectively so i chose the every tick method seen in the picture. It works, but when i came to the point that characters should also check if there are new obstacles when they move along theyre found path, the only working "logic" i could find was the "every 1 second->recalculate path" which is, together with the every tick for every character remove and set obstacle, really, really bad and i think the performance will also go down when its used in a real game.
Image

i bet i have to tie it to the moving part but i cant find anything that works.

Do you have an idea?
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Wed Oct 07, 2015 1:55 pm

There is no easy way to do that with the plugin. If the obstacle map change after a path is found, you have to recalculate it to be sure it's still valid. However, the map shouldn't change every tick, what you need to optimize is updating the map and finding new paths only when it's necessary.
B
65
S
27
G
24
Posts: 960
Reputation: 18,505

Post » Wed Oct 07, 2015 3:28 pm

Image
i changed it to this and it works, maybe someone can use it too :)
Thanks again!
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Wed Oct 07, 2015 3:33 pm

Glad you figured it out, can't wait to see what you might be brewing with those events ! ;)
B
65
S
27
G
24
Posts: 960
Reputation: 18,505

Post » Thu Oct 08, 2015 10:54 am

as soon i have something worthy to show i will show it here! :)

just realized that in the screenshot above theres some mixup, event 13 has the wrong parameters, instead of "character.nodeindex+1" there should be "loopindex" so it checks the whole remaing way for obstacles. With the parameter "character.nodeindex+1" it only checks the second next tile the character wants to move to.
I made this because i ran into another gamelogic problem, the "all seeing eye characters" :D
They shouldnt know where on the whole path people are standing but they do when i loop through the whole remaining path, the same problem appears when they calculate paths anyway, so i think i have to find another solution where i dont set the tiles characters standing on to non-walkable.
After some sleep i thought of using two tilemaps (im using at least two tilemaps anyway for ground, interior, etc..). First tilemap for ground and outer walls of buildings to provide the characters basic knowledge of theyre neighborhood and used for the initial path calculation. On the second tilemap i save the positions of characters and inner walls. While the character moves from tile to tile it could check if theres something in theyre field of view and whether its necessary to change the path. The characters then will need some form of memory for things they saw, a string where it remembers additional obstacles, that will be added before calculation and removed afterwards, so other characters can use the basic map with theyre own knowledge of temporary obstacles.
Im curious if this makes sense and works like i think :D
B
38
S
11
G
5
Posts: 485
Reputation: 5,340

Post » Thu Oct 08, 2015 3:29 pm

Don't worry, that make a lot of sense. However, implementing it correctly will be your next challenge ! ;)
B
65
S
27
G
24
Posts: 960
Reputation: 18,505

Post » Wed Dec 23, 2015 2:52 pm

@Magistross: thank you for this fine pice of code.
I'll use it iwith my new project and it works very well.
Image Image Image
B
40
S
22
G
15
Posts: 370
Reputation: 12,161

Post » Fri Jan 01, 2016 10:06 am

Really nice, thanks!.
B
29
S
11
G
20
Posts: 745
Reputation: 13,731

Post » Thu Jan 07, 2016 8:53 pm

Just updated ! Check out the first post.
B
65
S
27
G
24
Posts: 960
Reputation: 18,505

Post » Sun Mar 13, 2016 12:35 pm

when i enable easystar, i found the cpu usage is very high.
B
8
S
2
Posts: 11
Reputation: 522

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 2 guests