title: Check if items are overlapping
body: <p>I have a few rooms which are placed randomly so I have to check if a room is overlapping. The rooms have a size of 10x10 and are for test reasons placed exactly side by side (they don't overlap in the scene). The Floor is a Transform which consists out of 1 or more Transforms (in this case out of one square but for other forms it it could be 2 or more).</p>
  
  <p>To check if they are overlapping I have this function which doesn't work. Debug log is always something between 3 and 61..</p>
  
  <pre><code>public bool Overlapping()
  {
      //Lists for the position and of the size of each floor transform
      List&lt;Vector3&gt; positions = new List&lt;Vector3&gt;();
      List&lt;Vector3&gt; sizes = new List&lt;Vector3&gt;();
      //Check if floor consists out of more than 1 transform
      if (Floor.childCount &gt; 0)
          foreach (Transform t in Floor)
          {
              positions.Add(t.position);
              sizes.Add(t.lossyScale);
          }
      else
      {
          positions.Add(Floor.position);
          sizes.Add(Floor.lossyScale);
      }
  
      //Save old room pos and move it out of the way
      Vector3 position = this.transform.position;
      this.transform.position = new Vector3(0, 100, 0);
  
      //Check if any floor transform would overlap
      for (int i = 0; i &lt; positions.Count; i++)
      {
          //Make overlap box visible
          GameObject rec = GameObject.CreatePrimitive(PrimitiveType.Cube);
          rec.transform.localScale = sizes[i];
          rec.transform.localPosition = positions[i];
          rec.transform.localRotation = Quaternion.Euler(0, 0, 0);
  
          //Returns the colliders which are overlapping
          if (Physics.OverlapBox(positions[i], sizes[i] / 2).Length &gt; 0)
          {
              Debug.Log(Physics.OverlapBox(positions[i], sizes[i] / 2).Length);
              //return this room to it's old position
              this.transform.position = position;
              return true;
          }
      }
  
      //return this room to it's old position
      this.transform.position = position;
      return false;
  }
  </code></pre>
  
  <p>By the way for anyone reading (2/2016) <code>OverlapBox</code> is a brand-new call Unity just added to the latest verion.</p>
  
  <p><strong>Edit</strong>: As suggested by Joe I made the OverlapBox 'visible', but they seem to be in the correct positions and in the correct sizes (Red is my room, gray are the colliders)....</p>
  
  <p><a href="https://i.stack.imgur.com/1aEUz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1aEUz.png" alt="Colliders"></a></p>