detect collision on tilemap tile

I’m new to unity making a top down shooter that uses a tilemap for maps, and I’m trying to make the bullets that the player shoots disappear when it hits walls. this is the code that includes the moving script and where I tried to make it disappear. I tried tagging the tilemap layer with the “wall” tag, but resulted in the bullets running into the tiles and staying there with the same velocity until flying off.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BulletFire : MonoBehaviour
{
    public float bulletForce = 750.0f;
    
    void OnTriggerEnter2D(Collider2D target)
    {
        if (target.gameObject.tag == "firePoint")
        {
            GetComponent<Rigidbody2D>().AddForce(transform.right * bulletForce);
        }

        if (target.gameObject.tag == "wall")
        {
            Object.Destroy(gameObject);
        }
    }

    void OnBecameInvisible()
    {
        Object.Destroy(gameObject);
    }

}

again, I’m pretty new to Unity C# and I basically tried using most of the knowledge I know. Please help!

Make sure you are using the TileMapCollider2D component to add physics to your TileMap Object make sure the object has the “TileMap” Component, and not just the “Grid” component.
_
This will apply a Square Collider to all occupied tiles in the tile map, so you may want to duplicate your current TileMap Object and only populate it with the desired walls that you want to stop bullets, then add the collider component.
_
The TileMapCollider2D has the isTrigger Bool value in the inspector to tick as well since you are using OnTriggerEnter2D.

Nevermind, I managed to fix my problem by getting rid of the old code that I thought would delete the bullets and used this new script!

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BulletFire : MonoBehaviour
{
    public float bulletForce = 750.0f;
    
    void OnTriggerEnter2D(Collider2D target)
    {
        if (target.gameObject.tag == "firePoint")
        {
            GetComponent<Rigidbody2D>().AddForce(transform.right * bulletForce);
        }
    }

    void OnBecameInvisible()
    {
        Object.Destroy(gameObject);
    }

    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.name == "Tilemap_Walls")
        {
            Object.Destroy(gameObject);
        }
    }

}