//If touching, returns unit vector pointing from A towards B //else returns 0,0,0 public static Vector3 CheckRoomTouch(Bounds a, Bounds b, float minOverlap) { Interval a_x = new Interval(a.min.x, a.max.x); Interval a_y = new Interval(a.min.y, a.max.y); Interval a_z = new Interval(a.min.z, a.max.z); Interval b_x = new Interval(b.min.x, b.max.x); Interval b_y = new Interval(b.min.y, b.max.y); Interval b_z = new Interval(b.min.z, b.max.z); int roomTouchX = Interval.CheckTouching(a_x, b_x); int roomTouchY = Interval.CheckTouching(a_y, b_y); int roomTouchZ = Interval.CheckTouching(a_z, b_z); bool roomOverlapX = Interval.CheckOverlap(a_x, b_x, minOverlap); bool roomOverlapY = Interval.CheckOverlap(a_y, b_y, minOverlap); bool roomOverlapZ = Interval.CheckOverlap(a_z, b_z, minOverlap); //-.-- -.-- --.. if (roomOverlapX && roomOverlapY) { return(Vector3.forward * roomTouchZ); } if (roomOverlapZ && roomOverlapY) { return(Vector3.right * roomTouchX); } if (roomOverlapX && roomOverlapZ) { return(Vector3.up * roomTouchY); } return(Vector3.zero); }