Moving a object randomly without it being inside a wall

Hello, i am trying to make some types of pickups spawn inside a given area, although some usually get stuck within the walls, how would i fix this?

Code in question for moving objects:

for (int x = 0; x < garbage.Length; x++) 
             if (x < 5)
                 garbage[x].transform.position = new Vector3(Random.Range(-33.0f, 30.0f), 2.35f, Random.Range(30.0f, -35.0f)); 

Fixed it. Thanks.

Good day.

It’s very simple.

You should use colliders to detect if 2 objects are touching or inside eachother. If you detect a collision, then recalculate the position for spawining.