From f5c4c0e459c359bd784eb496f588e6a1c907201b Mon Sep 17 00:00:00 2001 From: NathanKell Date: Sun, 5 Nov 2023 01:06:10 -0800 Subject: [PATCH] Check for live rb and non-kinematic when restoring angular velocity --- Source/VesselModuleRotationRO.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Source/VesselModuleRotationRO.cs b/Source/VesselModuleRotationRO.cs index a158c9a7a3..e264618d05 100644 --- a/Source/VesselModuleRotationRO.cs +++ b/Source/VesselModuleRotationRO.cs @@ -274,10 +274,13 @@ private void FixedUpdate() if (_restoreAngularVelocity) // Restoring saved rotation if it was above the threshold { - // Debug.Log("[US] " + vessel.vesselName + " going OFF rails : restoring angular velocity, angvel=" + angularVelocity.magnitude); - ApplyAngularVelocity(); okToSaveAngularVelocity = false; - _restoreAngularVelocity = false; + if (vessel.rootPart.rb != null && !vessel.rootPart.rb.isKinematic) + { + // Debug.Log("[US] " + vessel.vesselName + " going OFF rails : restoring angular velocity, angvel=" + angularVelocity.magnitude); + ApplyAngularVelocity(); + _restoreAngularVelocity = false; + } } // Saving angular velocity (if we can), SAS mode, and check target hold status