Humanoid Control for Unity v4
|
Sockets can hold a Handles.
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.
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.
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.
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.
Depending on the type of socket and its GameObject handles are attached to sockets in various ways.
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.
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.
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”.
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.
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.
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.
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.
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.
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.
Public Types | |
enum | AttachMethod { Unknown , Parenting , ReverseParenting , Joint , StaticJoint , ColliderDuplication } |
Public Member Functions | |
void | Attach (GameObject objectToAttach) |
bool | Attach (GameObject objectToAttach, bool rangeCheck) |
virtual bool | Attach (Transform transformToAttach, bool rangeCheck=true) |
Tries to attach the given Transform to this socket. | |
virtual bool | Attach (Handle handle, bool rangeCheck=true) |
Tries to attach the given Transform to this socket. | |
virtual void | AttachStaticJoint (Transform objTransform) |
virtual void | Release (bool releaseSticky=false) |
Releases a Transform from the socket. | |
virtual void | ReleaseStaticJoint () |
void | OnDrawGizmosSelected () |
Static Public Member Functions | |
static Mesh | GenerateGizmoMesh1 () |
static Mesh | GenerateGizmoMesh () |
Public Attributes | |
GameObject | attachedPrefab |
A prefab which is used to attach to the socket at startup. | |
Transform | attachedTransform |
The Transform attached to this socket. | |
Handle | attachedHandle |
string | socketTag |
A tag for limiting which handles can be held by the socket. | |
AttachMethod | attachMethod = AttachMethod.Unknown |
bool | destroyOnLoad = false |
GameObjectEventHandlers | attachEvent |
A GameObject Event for triggering changes in the Transform held by the Socket. | |
Protected Member Functions | |
virtual void | MoveHandleToSocket (Transform socketTransform, Rigidbody handleRigidbody, Handle handle) |
virtual void | MoveRailToSocket (Transform socketTransform, Transform railTransform, Handle rail) |
virtual void | MoveHandleToSocket (Transform socketTransform, Handle handle) |
virtual void | MoveSocketToHandle (Transform socketTransform, Handle handle) |
virtual void | MoveSocketToHandle (Transform socketTransform, Rigidbody socketRigidbody, Handle handle) |
virtual bool | AttachRigidbody (Rigidbody objRigidbody, Handle handle, bool rangeCheck=true) |
void | AttachTransformParenting (Transform objTransform, Handle handle) |
virtual void | AttachRigidbodyParenting (Rigidbody objRigidbody, Handle handle) |
virtual void | AttachRigidbodyJoint (Rigidbody objRigidbody, Handle handle) |
virtual void | AttachRigidbodyReverseJoint (Rigidbody objRigidbody, Handle handle) |
Attach handle to socket using a static joint on the handle. | |
virtual void | AttachSocketParenting (Rigidbody objRigidbody, Handle handle, Rigidbody socketRigidbody) |
virtual void | MassRedistribution (Rigidbody socketRigidbody, Rigidbody objRigidbody) |
virtual bool | AttachStaticObject (Transform objTransform, Handle handle) |
virtual void | AttachSocketParenting (Transform objTransform, Handle handle, Rigidbody thisRigidbody) |
virtual void | AttachStaticJointRotY (Transform objTransform) |
IEnumerator | ClearReleasingTransform () |
virtual void | ReleaseRigidbodyParenting () |
virtual void | ReleaseRigidbodyJoint () |
void | ReleaseRigidbodyReverseJoint () |
virtual void | ReleaseSocketParenting (Rigidbody objRigidbody, Transform socketTransform) |
virtual void | MassRestoration (Rigidbody socketRigidbody, Rigidbody objRigidbody) |
virtual void | ReleaseStaticObject () |
void | ReleaseTransformParenting () |
void | ReleaseSocketParenting (Transform objTransform) |
virtual void | Awake () |
virtual void | Update () |
void | UpdateHolding () |
virtual void | OnSceneUnload (UnityEngine.SceneManagement.Scene _) |
Static Protected Member Functions | |
static void | DebugLog (string s) |
Protected Attributes | |
Transform | releasingTransform |
Transform | attachedTransformParent |
The parent of the attached transform before it was attached. | |
RigidbodyDisabled | rigidbodyDisabled = null |
float | originalMass = 1 |
bool | originalUseGravity = false |
Mesh | gizmoMesh |
Static Protected Attributes | |
static string[] | attachEventTypeLabels |
Properties | |
bool | isOccupied [get] |
Does the socket currently have a handle attached? | |
|
virtual |
Tries to attach the given Transform to this socket.
If the Transform has a Handle with the right Socket Tag it will be attached to the socket. Static and Kinematic Rigidbodies will be attached by parenting. Non-Kinematic Rigidbodies will be attached using a joint.
transformToAttach | The Transform to attach to this socket |
|
virtual |
Tries to attach the given Transform to this socket.
If the Handle has the right Socket Tag it will be attached to the socket. Static and Kinematic Rigidbodies will be attached by parenting. Non-Kinematic Rigidbodies will be attached using a joint.
handle | The Handle to attach to this socket |
Reimplemented in Passer.Humanoid.HandSocket.
|
virtual |
Releases a Transform from the socket.
Note that if the Transform is not taken out of the range of the socket or held by another Socket, it will automatically snap back to the Socket.
Reimplemented in Passer.Humanoid.HandSocket.
Transform Passer.Socket.attachedTransform |
The Transform attached to this socket.
If the socket holds a Handle, this will contain the Transform of the Handle. It will be null otherwise
|
protected |
The parent of the attached transform before it was attached.
This is used to restore the parent when the transform is released again.
string Passer.Socket.socketTag |
A tag for limiting which handles can be held by the socket.
If set (not null or empty) only Handles with the given tag will fit in the socket.
|
staticprotected |
GameObjectEventHandlers Passer.Socket.attachEvent |
A GameObject Event for triggering changes in the Transform held by the Socket.