private void FixedUpdateLateLate() { if (!vessel.loaded) { return; } // Checks to see if ground effect would have any significance if (((vessel.situation & LowFlying) == 0) || (vessel.radarAltitude > ActivateAltitude) || !vessel.mainBody.hasSolidSurface || !vessel.mainBody.atmosphere) { if (inRange) { // Previously in ground effect, just exited print(vessel.GetName() + " Exited Ground Effect range"); inRange = false; //ResetLiftValues(); liftingSurfaces = null; } return; } if (liftingSurfaces == null) { // Count the control surfaces if not done so //print(vessel.GetName() + " Entered Ground Effect range"); CountSurfaces(); } groundDir = vessel.gravityForPos.normalized; oceanNormal = -groundDir; // Use raytrace below to set the ground plane if (vessel.radarAltitude < wingSpan * 2.0f) { RaycastHit ray; // 1 << 15 hits anything that isn't a vessel or ocean if (Physics.Raycast(vessel.CoM, groundDir, out ray, wingSpan * 2.0f, 1 << 15)) { groundPlane.SetNormalAndPosition(ray.normal, ray.point); } else { groundPlane.distance = 0.0f; } } else { groundPlane.distance = 0.0f; } float newWingSpan = 1.0f; bool prevInGroundEffect = inGroundEffect; // Set true in AddGroundEffectForce, if any wing is close enough to the // ground inGroundEffect = false; // Loop trough all surfaces and change their lift // Also get the max wingspan for (int i = 0; i < liftingSurfaces.Count; i++) { FARWingAerodynamicModel surface = liftingSurfaces[i].surface; float mul = liftingSurfaces[i].groundEffectMultiplier; Part part = surface.part; Vector3 newLift = AddGroundEffectForce(part, surface.liftForce(), mul); // set aerodynamic overlay if (surface.liftArrow()) { // arrow length is 2x smaller than lift force as of 1.10 surface.liftArrow().Length = newLift.magnitude * 0.5f; surface.liftArrow().Direction = newLift; } newWingSpan = Math.Max(newWingSpan, ApproximateWingSpan(part)); } if (prevInGroundEffect && !inGroundEffect) { print(vessel.GetName() + " Exited Ground Effect"); } else if (!prevInGroundEffect && inGroundEffect) { print(vessel.GetName() + " Entered Ground Effect"); } //print("wingspan: " + newWingSpan); wingSpan = newWingSpan; }