Skip to main content

Crank

A class in Root.Township, Alta.Mechanisms.

A hand crank Mechanism: turns with the player's hand around its X axis and activates each time it passes a half or quarter turn.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private Transform ghostHandTransformTransform of the grabbing hand's ghost hand, followed while turning.
private Interactor interactorThe interactor turning the crank.
private Quaternion lastDentCrank rotation at the last activation.
private Vector3 lastHandPositionHand position around the crank when grabbed.
private Transform rotationRootTransform that is rotated on its X axis.
private Collider[] tightGripCollidersColliders used to re-check tight grip on the handle while turning.
private Crank.RotationType typeHalf or quarter turn per activation.

Properties​

1 private and internal property
MemberWhat it is
private float DentDistance { get; }Degrees of turn between activations: 170 for half turns, 80 for quarter turns.

Methods​

MemberWhat it is
protected override IEnumerator CheckAction() (iterator)Server coroutine: rotates the crank to follow the ghost hand each frame and calls OnActivated each time it turns past DentDistance.
protected override void OnInteracted(Interactable interactable, Interactor interactor)Stores the grabbing hand and its starting position around the crank.