using UnityEngine;

public class BulletDestroy : MonoBehaviour
{
    private void OnCollisionEnter2D(Collision2D collision)
    {
        // Only destroy the bullet if it has the "bullet" tag and collides with one of the specified barriers
        if ((CompareTag("bullet_1") || CompareTag("bullet_2")) &&
            (collision.gameObject.CompareTag("top_bar") ||
            collision.gameObject.CompareTag("bottom_bar") ||
            collision.gameObject.CompareTag("middle_bar") ||
            collision.gameObject.CompareTag("left_bar") ||
            collision.gameObject.CompareTag("right_bar")))
        {
            Destroy(gameObject);  // Destroy the bullet on collision with valid barriers
        }
    }
}
