Sockets

Sockets are GameObjects which can hold Handles.

Gizmo

A socket will be visible in the Scene View when selected as a wire version of the Handle Gizmo:

Attaching and Releasing

Attaching Handles using a Trigger Collider

When an trigger collider has been attached to the GameObject with the Socket an Handle will be attached to the Socket when it enters the trigger collider.

Attaching Handles using a Normal Collider

When a normal collider has been attached to the HameObject with the Socket a Handle will be attached to the Socket when it collides with the collider.

Attaching Handles using Function Calls

You can attach handles to the Socket GameObject by calling an Attach() function on the Socket. This will try to attach the Transform, Rigidbody or Handle parameter to the Socket.
On the other hand you can release Handles again by calling an Release() function on the Socket. This will release the currently attached Handle from the Socket.

Attaching Handles Prefab in the Editor

It is possible to attach a Handle prefab to a socket in the Unity editor. In this way the socket will start with a Handle attached.
This is done by assigning a Prefab to the Attached Prefab field of the Socket. This will automatically create an instance of the prefab which is attached to the socket.
When the Attached Prefab field is cleared again, the prefab instance attached to the socket is released and destroyed again.

Releasing Handles to another Socket

When an handle is attached to a socket and the Handle is attached to another socket it will be automatically released from the original socket.

The Socket Tag

With the Socket Tag field to is possible to limit the Handles which can attach to this socket to those who have the right Tag. This construction is using the standard Unity Tags.

Events

The Socket has one Event Handler which can be used to call function based on the attachment status.

The Attachment Implementation

Depending on the type of socket and its GameObject handles are attached to sockets in various ways.

A Static Socket…

… with a Non-Kinematic Rigidbody Handle

A non-kinematic Rigidbody will get a Joint which limits its movement to the location and orientation of the Socket. This joint is implemented using a Configurable Joint.
When the Handle is released, the joint is destroyed again.

… with a Kinematic Rigidbody Handle

A kinematic Rigidbody with an handle will the parented to the static Socket Transform. The result will be that the Transform of the Rigidbody is a child of the Socket Transform.
The Rigidbody will be temporarily removed. The settings will be conserved in a RigidbodyDisabled Component which is used to restore the Rigidbody when the Handle is released from the Socket.

… with a Static Handle

Static Handles cannot be attached to static Sockets. This will lead to a warning message in the Console: “Cannot attach static handle to static socket”.

A Kinematic Rigidbody Socket…

… with a Non-Kinematic Rigidbody Handle

If the Non-Kinematic Rigidbody Handle has one or more Joints or when it has constraints set, it will be attached to the Socket using a Joint. This joint is implemented using a Configurable Joint.
When the Handle is released, the joint is destroyed again.
In all other case, the non-kinematic Rigidbody will the parented to the kinematic Rigidbody Socket Transform. The result will be that the Transform of the Rigidbody is a child of the Socket Transform.
The Rigidbody will be temporarily removed. The settings will be conserved in a RigidbodyDisabled Component which is used to restore the Rigidbody when the Handle is released from the Socket.

… with a Kinematic Rigidbody Handle

A kinematic Rigidbody with an handle will the parented to the kinematic Rigidbody Socket Transform. The result will be that the Transform of the Rigidbody is a child of the Socket Transform.

… with a Static Handle

In this case, the kinematic Rigidbody Socket is parented to the static Handle Transform. The result will be that the Transform of the Scoket is a child of the Handle Transform.
The Rigidbody of the Socket will be temporarily removed. The settings will be conserved in a RigidbodyDisabled Component which is used to restore the Rigidbody when the Handle is released from the Socket.

A Non-Kinematic Rigidbody Socket…

… with a Non-Kinematic Rigidbody Handle

If the Non-Kinematic Rigidbody Handle has one or more Joints or when it has constraints set, it will be attached to the Socket using a Joint. This joint is implemented using a Configurable Joint.
When the Handle is released, the joint is destroyed again.
In all other cases, the non-kinematic Rigidbody will the parented to the kinematic Rigidbody Socket Transform. The result will be that the Transform of the Rigidbody is a child of the Socket Transform.
The Rigidbody will be temporarily removed. The settings will be conserved in a RigidbodyDisabled Component which is used to restore the Rigidbody when the Handle is released from the Socket.

… with a Kinematic Rigidbody Handle

A kinematic Rigidbody with an handle will the parented to the non-kinematic Socket Transform. The result will be that the Transform of the Rigidbody is a child of the Socket Transform.
The Rigidbody will be temporarily removed. The settings will be conserved in a RigidbodyDisabled Component which is used to restore the Rigidbody when the Handle is released from the Socket.

… with a Static Handle

In this case, the socket Rigidbody will be attached to the Handle using a Joint. This joint is implemented using a Configurable Joint such that it will follow the Handle’s Transform as closely as possible.
When the Handle is released, the joint is destroyed again.