Humanoid Control for Unity v4
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Properties | List of all members
Passer.Socket Class Reference

Description

Sockets can hold a Handles.

Attaching and Releasing

Attaching a Handle using Scripting

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 a Prefab with a Handle 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 a Handle 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.

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

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.

Inheritance diagram for Passer.Socket:
Passer.Humanoid.HandSocket

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?
 

Member Function Documentation

◆ Attach() [1/2]

virtual bool Passer.Socket.Attach ( Transform  transformToAttach,
bool  rangeCheck = true 
)
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.

Parameters
transformToAttachThe Transform to attach to this socket
Returns
Boolean indicating whether attachment succeeded

◆ Attach() [2/2]

virtual bool Passer.Socket.Attach ( Handle  handle,
bool  rangeCheck = true 
)
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.

Parameters
handleThe Handle to attach to this socket
Returns
Boolean indicating whether attachment succeeded

Reimplemented in Passer.Humanoid.HandSocket.

◆ Release()

virtual void Passer.Socket.Release ( bool  releaseSticky = false)
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.

Member Data Documentation

◆ attachedTransform

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

◆ attachedTransformParent

Transform Passer.Socket.attachedTransformParent
protected

The parent of the attached transform before it was attached.

This is used to restore the parent when the transform is released again.

◆ socketTag

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.

◆ attachEventTypeLabels

string [] Passer.Socket.attachEventTypeLabels
staticprotected
Initial value:
= {
"Never",
"On Attach",
"On Release",
"While Attached",
"While Released",
"When Changed",
"Always"
}

◆ attachEvent

GameObjectEventHandlers Passer.Socket.attachEvent
Initial value:
= new GameObjectEventHandlers() {
label = "Hold Event",
tooltip =
"Call functions using what the socket is holding\n" +
"Parameter: the GameObject held by the socket",
eventTypeLabels = attachEventTypeLabels
}

A GameObject Event for triggering changes in the Transform held by the Socket.


The documentation for this class was generated from the following file: