Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

tilemap collision confusion

Discussion in '2D Experimental Preview' started by shottyB, Sep 2, 2016.

  1. shottyB

    shottyB

    Joined:
    Aug 24, 2016
    Posts:
    2
    Hi there.

    Trying to get my feet wet with the tilemap system but I'm struggling to understand how to delete a specific tile- in this case a pacman dot set on the grid.



    The dots are set on the tilemap with the layer name "wacdots"

    I'm currently using the following script attached to the "wacdots" layer:

    Code (CSharp):
    1.     void OnTriggerEnter2D(Collider2D other)
    2.     {
    3.         if (other.name == "wacman") {
    4.             Destroy(this.gameObject);
    5.         }
    6.     }
    This destroys the entire tilemap, where as I'm trying to delete the specific tile that triggered the collision. I'm struggling to understand how to access the specific tile being triggered.

    Any help would be greatly appreciated, thanks.
     
    Last edited: Sep 2, 2016
  2. Johaness_Reuben

    Johaness_Reuben

    Joined:
    Jan 27, 2016
    Posts:
    253
    The TileMap is the GameObject which renders the tiles. So you don't want to destroy it. Check out the documentation for TileMap in the docs that got downloaded/installed with the Preview.