@@ -33,7 +33,7 @@ public class ModuleIRServo : PartModule, IRescalable, IJointLockState
3333
3434 //BEGIN Mechanism related KSPFields
3535 [ KSPField ( isPersistant = true ) ] public bool freeMoving = false ;
36- [ KSPField ( isPersistant = true ) ] public bool isMotionLock ;
36+ [ KSPField ( isPersistant = true ) ] public bool isMotionLock = false ;
3737 [ KSPField ( isPersistant = true ) ] public bool limitTweakable = false ;
3838 [ KSPField ( isPersistant = true ) ] public bool limitTweakableFlag = false ;
3939
@@ -487,6 +487,8 @@ public void OnVesselGoOffRails (Vessel v)
487487
488488 Logger . Log ( "[OnVesselGoOffRails] Started for " + part . name , Logger . Level . Debug ) ;
489489
490+ Logger . Log ( "[OnVesselGoOffRails] Rebuilding Attachments" , Logger . Level . Debug ) ;
491+ BuildAttachments ( ) ;
490492
491493 if ( joint )
492494 {
@@ -561,17 +563,14 @@ public override void OnLoad(ConfigNode config)
561563 {
562564 Logger . Log ( "[OnLoad] Start" , Logger . Level . Debug ) ;
563565
564- base . OnLoad ( config ) ;
566+ // base.OnLoad (config);
565567
566568 //save persistent rotation/translation data, because the joint will be initialized at current position.
567569 rotationDelta = rotation ;
568570 translationDelta = translation ;
569571
570572 InitModule ( ) ;
571573
572- Logger . Log ( "[OnLoad] Rebuilding Attachments" , Logger . Level . Debug ) ;
573- BuildAttachments ( ) ;
574-
575574 Logger . Log ( "[OnLoad] End" , Logger . Level . Debug ) ;
576575 }
577576 /// <summary>
@@ -637,6 +636,12 @@ protected virtual void AttachToParent()
637636 {
638637 Transform fix = FixedMeshTransform ;
639638 //first revert position to part position
639+ if ( fix == null || part == null || part . transform == null || part . parent == null )
640+ {
641+ Logger . Log ( "[AttachToParent] part, parent or transform is null" , Logger . Level . Debug ) ;
642+ return ;
643+ }
644+
640645 fix . position = part . transform . position ;
641646 fix . rotation = part . transform . rotation ;
642647
@@ -704,10 +709,10 @@ protected virtual void BuildAttachments()
704709 AttachToParent ( ) ;
705710 }
706711
707- var node = part . FindAttachNodeByPart ( part . parent ) ;
712+ // var node = part.FindAttachNodeByPart (part.parent);
708713
709- if ( translateJoint && ( node == null || ! ( node . id . Contains ( bottomNode ) || part . attachMode == AttachModes . SRF_ATTACH ) ) )
710- translateAxis *= - 1 ;
714+ // if(translateJoint && (node == null || !(node.id.Contains(bottomNode) || part.attachMode == AttachModes.SRF_ATTACH)))
715+ // translateAxis *= -1;
711716
712717 ReparentFriction ( part . transform ) ;
713718 failedAttachment = false ;
@@ -767,7 +772,7 @@ public override void OnStart(StartState state)
767772 if ( ModelTransform == null )
768773 Logger . Log ( "[MMT] OnStart ModelTransform is null" , Logger . Level . Warning ) ;
769774
770- BuildAttachments ( ) ;
775+ BuildAttachments ( ) ;
771776
772777 if ( limitTweakable )
773778 {
@@ -1061,7 +1066,7 @@ public static float AngleSigned(Vector3 v1, Vector3 v2, Vector3 n)
10611066 /// </summary>
10621067 /// <returns>The real rotation.</returns>
10631068 public float GetRealRotation ( )
1064- {
1069+ {
10651070 Vector3 v1 , v2 , n ;
10661071 if ( rotateAxis == Vector3 . forward || rotateAxis == Vector3 . back )
10671072 {
@@ -1149,7 +1154,7 @@ protected virtual void UpdatePosition()
11491154 Interpolator . Update ( TimeWarp . fixedDeltaTime ) ;
11501155
11511156 float targetPos = Interpolator . GetPosition ( ) ;
1152- float currentPos = rotateJoint ? GetRealRotation ( ) : GetRealTranslation ( ) ;
1157+ float currentPos = rotateJoint ? rotation : translation ; //rotateJoint ? GetRealRotation() : GetRealTranslation();
11531158
11541159 if ( lastRealPosition == 0f )
11551160 lastRealPosition = currentPos ;
0 commit comments