Check if 2D object is at position

I have seen how to do this with a 3D sphere, but when I try to replicate it with a 2D box it has not worked (maybe it is the way I am trying to do it). I have a random position that I know and I just want to check if there is a 2D object in the position.

    public bool Corridors() {

        //create random location-sub/add 1 to prevent it from going to boarders
        int randx = Random.Range(((width / 2) * -1) + 1, (width / 2) - 1);
        int randy = Random.Range(((height / 2) * -1) + 1, (height / 2) - 1);

        //position to insert/check
        Vector2 rand_pos = new Vector2(randx,randy);
        
        **//check if there is something at that position**

        //clone wall to be at new random location
        Instantiate(wall, rand_pos, Quaternion.identity);

        //wall placement is good
        return true;
    }

Probably the easiest way is to do a Raycast to see if it collides with anything at that position. That means the objects that you want to detect need collider components, and make sure they’re not Is Trigger. Look over this documentation - it’s pretty simple: