Detect if there is something between fire and object

So I have a bomb that when it’s detonated, creates two fires on opposites sides of the bomb, and I want the fire to make damage only if there isn’t any escenary between the fire and an object. I’ve tried the following but it doesn’t detect the object. I’m quite new to raycasting so sorry if this is stupid.

    public int enemyDamage;
    public int objectDamage;
    public GameObject bullet;
    bool count = false;
    float timer;

    public void OnTriggerEnter2D(Collider2D hitInfo)
    {
        DestructableObject destructableObject = hitInfo.GetComponent<DestructableObject>();
        Enemy enemy = hitInfo.GetComponent<Enemy>();
        CharacterHealth player = hitInfo.GetComponent<CharacterHealth>();

        if (destructableObject != null)
        {
            RaycastHit2D hit = Physics2D.Raycast(transform.position, hitInfo.transform.position - transform.position);

            if (hit.collider != null && hit.collider.CompareTag("Destructable") )
            {
                destructableObject.TakeDamage(objectDamage);
            }
        }

        if (enemy != null)
        {
            enemy.TakeDamage(enemyDamage);
        }

        if (player != null)
        {
            player.TakeDamage(enemyDamage);
        }
        count = true;
    }

    private void Update()
    {
        bullet.GetComponent<Rigidbody2D>().gravityScale = 0;
        bullet.GetComponent<Rigidbody2D>().velocity = new Vector2(0f, 0f);
        bullet.GetComponent<Rigidbody2D>().angularVelocity = 0;

        if (count)
        {
            timer += 1 * Time.deltaTime;
        }

        if (timer >= 3)
        {
            Destroy(bullet);
        }
    }

first of all why are you setting a rigidbodys velocity and stuff every frame? If you don’t want it have motion you should just set kinimatic to true in the editor. Also using GetCompoment every frame is bad, you should store the rigidbody as a variable in your class if you want to use it multiple times.

In regards to your question. I am not sure why you are doing a raycast at all. By getting DestructableObject and checking if it is not null you are already seeing if you’ve hit an object. If you are trying to see if there is another destructible object between the fire and the destructible object you hit then you are on the right track but probably want to include a distance in your raycast that is the distance between the two objects.

If you are wondering why your ray isn’t hitting anything it probably has to do with where the pivot points on your objects are. using Transform.position means you are drawing a line from your pivot point so make sure that is what you want.