Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - maaton

Pages: [1]
1
Support / Detach Prefab From Tiles at Runtime
« on: November 11, 2014, 10:56:46 pm »
Hi.

first of all I must say, 2dtoolkit tile map is simply awsome and it is a delight to use it. One question:

Every time I update the map and use SetTile() all tiles that have prefabs attached to them are instantiated again and Start() is called again on their script.
Is there a way to somehow "detach" all prefabs at runtime after I don't need them anymore? I use SetTile() quite often and I just couldn't figure this one out.

Thank you for your help in advance!

Marton

2
Support / Check against TileMap.TileInfo.stringVal freezes Unity
« on: June 01, 2014, 12:16:58 am »
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


Pages: [1]