// Thanks to taniwha's Extraplanetary launchpads! public Bounds GetAABB(ShipConstruct a_Ship) { PartHeightQuery partHeight = null; Bounds aabb = new Bounds(); bool initialize = true; for (int i = 0; i < a_Ship.parts.Count; i++) { Part currentPart = a_Ship[i]; Collider[] colliders = currentPart.transform.FindChild("model").GetComponentsInChildren<Collider>(); for (int j = 0; j < colliders.Length; j++) { Collider currentCollider = colliders[j]; if (currentCollider.gameObject.layer != 21 && currentCollider.enabled) // Not sure where the 21 is coming from, have to ask taniwha { if (initialize) { initialize = false; aabb = currentCollider.bounds; } else { aabb.Add(currentCollider.bounds); } float lowest = currentCollider.bounds.min.y; if(partHeight == null) { partHeight = new PartHeightQuery(lowest); } partHeight.lowestPoint = Mathf.Min(partHeight.lowestPoint, lowest); if(partHeight.lowestOnParts.ContainsKey(currentPart)) { partHeight.lowestOnParts[currentPart] = Mathf.Min(partHeight.lowestOnParts[currentPart], lowest); } } } } for(int i = 0; i < a_Ship.parts.Count; i++) { a_Ship[i].SendMessage("OnPutToGround", partHeight, SendMessageOptions.DontRequireReceiver); } return new Bounds(); }