KAS.KASModuleAttachCore.AttachStatic C# (CSharp) Method

AttachStatic() public method

public AttachStatic ( float breakForce = 10 ) : void
breakForce float
return void
        public void AttachStatic(float breakForce = 10)
        {
            KAS_Shared.DebugLog("JointToStatic(Base) Create kinematic rigidbody");
            if (StaticAttach.connectedGameObject) {
              Destroy(StaticAttach.connectedGameObject);
            }
            var obj = new GameObject("KASBody");
            var objRigidbody = obj.AddComponent<Rigidbody>();
            objRigidbody.isKinematic = true;
            obj.transform.position = this.part.transform.position;
            obj.transform.rotation = this.part.transform.rotation;
            StaticAttach.connectedGameObject = obj;

            KAS_Shared.DebugLog("JointToStatic(Base) Create fixed joint on the kinematic rigidbody");
            if (StaticAttach.fixedJoint) {
              Destroy(StaticAttach.fixedJoint);
            }
            FixedJoint CurJoint = this.part.gameObject.AddComponent<FixedJoint>();
            CurJoint.breakForce = breakForce;
            CurJoint.breakTorque = breakForce;
            // FIXME: Just don't set connected body when attaching to static.
            CurJoint.connectedBody = objRigidbody;
            StaticAttach.fixedJoint = CurJoint;
            attachMode.StaticJoint = true;
        }