Skip to main content

CustomFixedJoint

A class in Root.Township, the global namespace.

A scripted stand-in for a fixed joint used when a pickup's joint type is CustomFixedJoint: each physics step it snaps the held rigidbody to the hand, optionally capped at arm's length. Added to the interaction point by PickupJoints.

Constructors​

MemberWhat it is
CustomFixedJoint()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

12 private and internal fields
MemberWhat it is
private Rigidbody attachedObjectThe held rigidbody being moved.
private Vector3 gripPointPositionLast grip point position read in FixedUpdate.
private bool isActiveWhether FixedUpdate moves the object.
private bool isCollisionEnabledIf false, collisions between hand and object are ignored while active.
private bool isLimitingArmLengthWhether the object is kept within arm's length of the shoulder.
private Vector3 limitedPositionHand position after the arm-length cap.
private Vector3 offsetHeld object's position offset in this transform's local space.
private Rigidbody rigidbodyThis object's own rigidbody, whose colliders are ignored against the held object.
private Quaternion rotationOffsetHeld object's rotation relative to this transform.
private Vector3 rotEulersRotation offset as Euler angles; reapplied to rotationOffset each step.
private Transform shoulderShoulder transform from the arm IK, used for the reach limit.
private Vector3 shoulderPositionLast shoulder position read in FixedUpdate.

Properties​

MemberWhat it is
Controller Controller { get; set; }The hand controller holding the object; its grip point and arm length are used for the reach limit.

Methods​

MemberWhat it is
void Disable()Stops moving the object and turns collisions between hand and object back on.
void Enable()Starts moving the object and, unless collisions are enabled, ignores collisions between hand and object.
void Setup(Rigidbody attachedObject, Vector3 offset, Quaternion rotationOffset, Interactor interactor, bool isCollisionEnabled = false)Sets the held rigidbody, offset, rotation offset, collision setting and the arm's shoulder from the interactor. Logs the offsets.
3 private and internal methods
MemberWhat it is
private void FixedUpdate()Zeroes the object's velocity and places it at the hand (or the arm-length limit) plus the stored offset and rotation.
private void IgnoreCollisions(bool isIgnoring)Sets ignore-collision between every collider under the hand and under the held object.
private void Start()Works out the offset from current positions if none was given, then calls Enable.