Hi,
First of all I must say that I am really satisfied with 2dtoolkit as it has really saved me a lot of hassle putting together a tileMap based IOS game. Lately I've been trying to implement a simple custom A* pathfinding algorithm with 2d Toolkit Tilemap and everything
seems to be working fine without any walls to bump into. However, every time the algorithm checks against tiles tagged as a walls (a string value "wall" was set in the editor's data tab) Unity freezes for good and has to be restarted. Here is the method that checks if there is a wall at a given tile coordinate:
private bool isWallAtTileCoord (Vector2 tileCoord)
{
int tileId = tileMap.GetTile ((int)tileCoord.x, (int)tileCoord.y, 0);
tk2dRuntime.TileMap.TileInfo tileInfo = tileMap.GetTileInfoForTileId (tileId);
return tileInfo.stringVal == "wall";
}
After several debugging attempts to find out what's happening it all came down to this method, this is the only place where the problem can be, without this check for "walls" the algorithm works fine (The character finds the shortest path on the tileMap and follows it). This information (tileInfo.stringVal == "wall" true or false) is passed to another method that looks for adjacent tiles in four directions, determines if a tile is walkable, creates a list out of the walkable tiles based on their tile coordinates and later on in another method the scores are calculated for each tile etc. (as in any basic A* algorithm).
I was able to simply Debug.Log() the string values of the tiles with given "wall" data without any problems, but every time I want this method to actually return true (find the "wall" string in the tileInfo) and choose a path where a wall eventually has to be avoided, Unity freezes without any error messages as it would with an infinite loop. Do you guys have any idea what on earth could be going on here? I would really appreciate any help as it is driving me crazy by now. If necessary I can provide the rest of the code.
Marton