Physics2D Raycast not colliding with Tilemap Collider

Hi there,

I’ve got a Tilemap which draws up a random dungeon at runtime (top-down 2D roguelike). I’m trying to create a fog-of-war effect but the Raycasts are just going straight through the walls (tilemap collider). Can anyone point me in the right direction? I’m happy to provide more info.

private void UpdateVision()
    {
        Vector3Int playerPosition = groundTile.WorldToCell(transform.position);

        for (int x = sightRadius * -1; x <= sightRadius; x++)
        {
            for (int y = sightRadius * -1; y <= sightRadius; y++)
            {        
                RaycastHit2D hit = Physics2D.Raycast(new Vector2(playerPosition.x, playerPosition.y), new Vector2(x, y));
                Debug.DrawRay(new Vector2(playerPosition.x, playerPosition.y), new Vector2(x, y));
                
                if (hit.collider != null)
                {
                    occlusionTile.SetTile(new Vector3Int(playerPosition.x + x, playerPosition.y + y, 0), null);
                }
                
            }
        }
    }

Did you ever find the answer to this???