![]() | ILinkSourceBreakCurrentLink Method |
Namespace: KASAPIv2
void BreakCurrentLink( LinkActorType actorType )
// Disconnects the source part from its target. Only once source can be connected on the part. // And it can be connected to the exactly one target. public static void DisconnectParts(Part srcPart) { var source = srcPart.FindModulesImplementing<ILinkSource>() .FirstOrDefault(s => s.linkTarget != null); if (source == null) { Debug.LogWarningFormat("Part is not connected to anything"); return; } // LinkActorType.API tells the implementation to not execute any user facing effects on the // link. See LinkActorType for more details. source.BreakCurrentLink(LinkActorType.API); }
public class ILinkSourceExample_BreakFromPhysyicalMethod : MonoBehaviour { public ILinkSource linkSource; // This method is called by Unity core during the physics update. IEnumerable OnJointBreak(float force) { Debug.LogWarningFormat("Link is broken with force: {0}", force); // Don't break the link from the physics methods! yield return new WaitForEndOfFrame(); // Now it's safe to change the physical objects. if (linkSource != null && linkSource.linkTarget != null) { linkSource.BreakCurrentLink(LinkActorType.Physics); } } }