Skip to main content

RotatePickupPuzzleOLD

A class in Root.Township, the global namespace.

Old component that rotates objects around an axis to follow the hands on their handle pickups. Kept for reference; the OLD name marks it as superseded.

Constructors​

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

Fields​

3 private and internal fields
MemberWhat it is
private int lastInteractorCountHow many hands were found last time, used to detect changes.
private bool needsToZeroSet when the hand count changes so Advanced resets its last direction and doesn't jump.
private RotationBucket[] partsToRotateThe rotating parts with their handles and settings.

Methods​

11 private and internal methods
MemberWhat it is
private void Advanced(RotationBucket item)Rotates a part in its local space toward the hands' midpoint, clamped to clampDegrees from identity.
private void Awake()Checks references, records starting tracking vectors and hooks every handle's interaction start and end events.
private Quaternion ClampAroundIdentity(Quaternion rotation, float degrees)Limits a rotation to a number of degrees away from identity.
private Vector3 GetMidPoint(Pickup[] pickups, Vector3 baseObjectPos)Returns the average interaction point of all hands on the pickups, or the object position if none. Flags a reset when the hand count changes.
private void InteractionEnded(Interactable interactable, Interactor interactor)Disables the component once no handle is held.
private void InteractionStarted(Interactable interactable, Interactor interactor)Enables the component so Update runs while a handle is held.
private void OnDrawGizmosSelected()Editor: draws each part's rotation axis in green.
private void OnValidate()Normalizes each part's rotation axis.
private void Simple(RotationBucket item)Rotates a part around its world-space axis by the change in direction to the hands' midpoint.
private void Test()Unused test method with no effect.
private void Update()Each frame, updates the tracking point and rotates every part with Simple or Advanced.