int distributeObject(HRigidBody h) { bool done = false; HRigidBody[] tmp = FindObjectsOfType <HRigidBody> (); int loop = 0; float buffer = bounds / 16f; float buffer2 = buffer * 2; while (!done) { h.transform.position = new Vector3((bounds - buffer2) * Random.value + buffer, (bounds - buffer2) * Random.value + buffer, (bounds - buffer2) * Random.value + buffer); if (tmp.Length == 1) { done = true; } else { for (int m = 0; m < tmp.Length; m++) { if (h.name != tmp [m].name) { bool overlap = CheckBoundingBoxes(h, tmp [m]); if (!overlap) { done = true; } } } } for (int l = 0; l < planeIndices.Length; l++) { int result = narrowPhase.CheckGroundPlaneContacts(new CollisionObject(h, planeIndices [l])); if (result == 2 | result == 1) { done = false; } } loop++; if (loop > 100) { return(1); } } h.oldPosition = h.transform.position; return(0); }