Enemy projectiles pass through the tilemap (they don't detect collisions)

Hi, I made an enemy that shoots the player, I wish that when the projectiles hit specific tilemaps (walls,platforms) the bullets disintegrated, but they are not.
My projectile script:

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

public class ProjectTile : MonoBehaviour
{
    public float speed;

    private Transform player;
    private Vector2 target;
    private GameObject health;
    public int damage;
   // public Animator anim;
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player").transform;
        target = new Vector2(player.position.x, player.position.y);
    }
   
    void Update()
    {
        transform.position = Vector2.MoveTowards(transform.position, target, speed * Time.deltaTime);

        if (transform.position.x == target.x && transform.position.y == target.y)
        {
            Destroy(gameObject);
        }
    }

    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("Player"))
        {
            health = GameObject.Find("Player");
            health.GetComponent<HeartSystem>().TakeDamage(damage);
            //anim.SetTrigger("destroy");
            Destroy(gameObject);
        }

      
    }
   
   
}

7113634--848914--Zrzut ekranu 2021-05-06 132537.png 7113634--848920--Zrzut ekranu 2021-05-06 132554.png

First, check the “Is Trigger” box on the TileMap Collider. Next, give your tilemap a Tag like Player, but call it Ground or Walls or something. Then just repeat what you did for colliding with the player. You should be able to stick in another if statement after your first. Not sure If you can do an else if here.

if (other.CompareTag("Ground"))
        {
             Destroy(gameObject);
             // and any other code you want
        }

You can also add the || , or the “Or” Operator in your original code. This would basically say if it collides w/ the player OR the ground then do whatever.

if (other.CompareTag("Player" || other.CompareTag("Ground))
        {
            health = GameObject.Find("Player");
            health.GetComponent<HeartSystem>().TakeDamage(damage);
            //anim.SetTrigger("destroy");
            Destroy(gameObject);
        }