Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Tilemap: can't find a way to affect a tile content

Discussion in 'Scripting' started by glad, Mar 6, 2020.

  1. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    Hi! :)

    I have tiles that I want to animate in runtime.. Animate means moving/fading.. The problem I faced is that I can't get any object information to do transform manipulations. I tried for example the following:

    Code (CSharp):
    1. var tile = tilemap.GetTile<Tile>(pos);
    2. if (tile != null)
    3. {
    4.    // tile.gameObject == null
    5.    tile.gameObejct.transform.position = ...l
    6. }
    tile.gameObject is null. So I can't get it. :(

    How to get the actual gameobject from a tile ?

    Thanks in advance!
     
  2. Yoreki

    Yoreki

    Joined:
    Apr 10, 2019
    Posts:
    2,605
    I dont know if i'm the best person to answer this question, but out of curiosity i did some research.
    It seems (https://www.reddit.com/r/Unity2D/comments/7rlzqn/20172_tilemaps_are_moving_tiles_possible/) like you cannot freely move tiles in tilemaps - unless such a feature was recently added. So you will need to basically remove the tile, animate a sprite to look like the tile moving from one spot to the next, and then put the tile back there in the tilemap.
    I'd say based on this, it should be the same for fading.

    Someone with some experience on tilemaps will probably add to this answer if there are more elegant solutions, or correct me if i'm wrong.
     
  3. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    I see.. Probably I will refuse using tilemap for objects that could be translated.
    Thanks a lot!