> Updated the plugin using the 0.4.1 version of EasyStarJS. Since I practically did this on my lunch break at work, absolutely NO testing whatsoever was done so please try it and report your success here. <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">
>
> https://magistross.github.io/files/easy ... p_1_02.zip
>
Sweet!
Thanks for putting this together so quickly. I will test it out as soon as I can next week. I have to get through another project tomorrow.
Based on a minor tweak to the example .capx (I had to put the "destroy" under the "On path 'test' found", rather than every tick) and 10 minutes of testing, it appears to work great!
Attempt at optimization for garbage collection:
Although the example was only using about 125 objects and 6% CPU time on my Surface Pro 4, I thought I would try to optimize garbage collection by not destroying and creating new nodes every time a path was found. Instead, I created a grid of nodes on start of layout and set them all as invisible. When a path is found, I set only the path nodes to visible.
Result:
With this "optimization", CPU usage was insignificant, but frame rate dropped to an unplayable 25 fps, with a noticeable pause in pathfinding. I assume this frame rate drop is happening because of a GPU bottleneck, but I had no idea that it would be so dramatic.
Conclusion:
-Having a node object for every grid tile is more computationally expensive than just creating and destroying nodes as needed for a 28 x 16 grid.
-Better yet, don't put any node objects on screen at all. Instead of actual objects, compute direction based on the nearest tilemap square.
Further work:
I need to play around with things now to figure out how to get AIs to follow the path. I will be working in 3D with physics, so path following will be a bit more complicated, but EasyStar.js seems to be rock solid. Thank you! Thank you for putting this together -- you saved me a ton of time!