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
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.
Behavior files v1.03
Small update to correct a bug with the "SetTileAt" override. Also added a condition to test if a tile is walkable and an expression to get the cost from a particular tile.
**New**
Behavior files v1.04
C3 version - automatic conversion (seems to work perfectly but use at own risk)
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.