public void Eject()
{
if (headState == PlugState.Locked && ejectEnabled) {
Deploy();
retract.full = false;
cableJointLength = maxLenght;
Vector3 force = winchAnchorNode.TransformDirection(Vector3.forward) * ejectForce;
Rigidbody rb = connectedPortInfo.module
? connectedPortInfo.module.part.Rigidbody
: headTransform.GetComponent<Rigidbody>();
// Apply ejection force on the projectile and enhance collision check mode.
rb.AddForce(force, ForceMode.Force);
StartCoroutine(LimitFreeFlyDistance(rb, cableJointLength));
rb.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic;
KAS_Shared.DebugLog("Set collision mode to ContinuousDynamic on part {0}", rb);
// Compensate recoil on the winch.
this.part.Rigidbody.AddForce(-force, ForceMode.Force);
fxSndEject.audio.Play();
}
}