public void CreateJoint(Rigidbody originBody, Rigidbody targetBody, LinkType type, Vector3 anchorPosition) { if (HighLogic.LoadedSceneIsFlight && this.part != null && this.part.attachJoint != null && this.part.attachJoint.Joint != null) { this.part.attachJoint.Joint.breakForce = Mathf.Infinity; this.part.attachJoint.Joint.breakTorque = Mathf.Infinity; if (!this.IsFreeAttached && this.Target != null && this.Target.part != null && this.Target.part.attachJoint != null && this.Target.part.attachJoint.Joint != null) { this.Target.part.attachJoint.Joint.breakForce = Mathf.Infinity; this.Target.part.attachJoint.Joint.breakTorque = Mathf.Infinity; } } var breakForce = type.GetJointStrength(); this.LinkType = type; if (!this.IsFreeAttached) { var moduleActiveStrut = this.Target; if (moduleActiveStrut != null) { moduleActiveStrut.LinkType = type; this.IsOwnVesselConnected = moduleActiveStrut.vessel == this.vessel; } } else { this.IsOwnVesselConnected = this.FreeAttachPart.vessel == this.vessel; } if (!this.IsEnforced || Config.Instance.GlobalJointWeakness) { this._joint = originBody.gameObject.AddComponent<ConfigurableJoint>(); this._joint.connectedBody = targetBody; this._joint.breakForce = this._joint.breakTorque = breakForce; this._joint.xMotion = ConfigurableJointMotion.Locked; this._joint.yMotion = ConfigurableJointMotion.Locked; this._joint.zMotion = ConfigurableJointMotion.Locked; this._joint.angularXMotion = ConfigurableJointMotion.Locked; this._joint.angularYMotion = ConfigurableJointMotion.Locked; this._joint.angularZMotion = ConfigurableJointMotion.Locked; this._joint.projectionAngle = 0f; this._joint.projectionDistance = 0f; this._joint.anchor = anchorPosition; } else { this._manageAttachNode(breakForce); } this.PlayAttachSound(); }