title: How to make a destructible tilemap? unity 2d
body: <p>I'm currently making a terraria-like game. And I'm at the stage of adding and breaking blocks. How can I check for collision and make the block that the bullet touched disappear?</p>
  <p>Here is my current tilemap script :</p>
  <pre><code>using UnityEngine;
  using UnityEngine.Tilemaps;
  
  public class DestructibleTiles01 : MonoBehaviour
  {
      public Tilemap destructibleTilemap;
  
      private void Start()
      {
          destructibleTilemap = GetComponent&lt;Tilemap&gt;();
      }
  
      private void OnCollisionEnter2D(Collision2D collision)
      {
          if (collision.gameObject.CompareTag(&quot;TerraFormingBullet&quot;))
          {
              Vector3 hitPos = Vector3.zero;
              foreach(ContactPoint2D hit in collision.contacts)
              {
                  hitPos.x = hit.point.x - 0.01f * hit.normal.x;
                  hitPos.y = hit.point.y - 0.01f * hit.normal.y;
                  destructibleTilemap.SetTile(destructibleTilemap.WorldToCell(hitPos), null);
              }
          }
      }
  }
  </code></pre>
  <p>for some odd reason, nothing happens when my projectile collides with the tilemap. I followed a tutorial on how to make this destructible tilemap but because I'm new to C#, I don't fully understand everything in this script and thus, I can't debug this code. Any help is appreciated, thanks!</p>