Search Unity

Destroy just one tiles on tilemaps

Discussion in '2D' started by Magixapps, Feb 20, 2018.

  1. Magixapps

    Magixapps

    Joined:
    Mar 4, 2017
    Posts:
    55
    Hi,
    i have create 2d game with tilemaps (on unity 2017.3.0f3)

    I want when my player collide with one tiles, that tiles are delete.
    But my probleme is when player collide with one tiles, all my tile map are destroy not only that one tiles.

    (you can see what i want exactly on image)



    Its possible?
    Thank you!
     
  2. weezle1

    weezle1

    Joined:
    Aug 19, 2017
    Posts:
    1
    Did you figure out how to do this? I'm currently running into this issue and have worked around it but I would really like to see if this is possible to do.
     
  3. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    113
    Post your code.
     
  4. jspink

    jspink

    Joined:
    Dec 16, 2015
    Posts:
    2
    You can do something like this ...

    Code (CSharp):
    1.  
    2. // set x,y to the cell coordinates and ...
    3. Vector3Int cell = new Vector3Int(x, y, 0);
    4.  
    5. if (tileMap.HasTile(cell)) {
    6.      tileMap.SetTile(cell, null);
    7. }
    8.