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.


Messages - maaton

Pages: [1]
1
Support / Re: Detach Prefab From Tiles at Runtime
« on: November 12, 2014, 07:36:15 pm »
I need to update both layers at the same time so I think I'll just put extra copies of the associated tiles to the tilesheet, one with prefab, one without.

Anyway,

thanks for your promt reply and great support!

2
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

3
Support / Re: Check against TileMap.TileInfo.stringVal freezes Unity
« on: June 01, 2014, 07:30:51 pm »
Thank you for your reply. I isolated the problem to a separate scene to find out if it is really the string comparison that is causing the problem and everything worked fine. With this exact same method I was able to print out messages if I click on a "wall tile" so I figured out this has nothing to do with the string comparison. It must be something with my algorithm which I don't really get because if a "wall" check returns false everything works fine. The problem only occurs when it eventually returns true. I tried to trace the root of the problem so I modified my code a bit to get a glimpse what's going on. After more debugging I managed to get an error

IndexOutOfRangeException: Array index is out of range.
tk2dRuntime.TileMap.Layer.GetRawTileValue (Int32 x, Int32 y, System.Int32& value) (at Assets/TK2DROOT/tk2dTileMap/Code/tk2dTileMapChunks.cs:387)...

So apparenrly this is not 2dtoolkit issue after all... Thank you, anyway!

4
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]