Skip to main content

RotatePickup

A class in Root.Township, the global namespace.

Rotates an object around one axis as players drag its pickups, like turning a wheel. The turn speed is capped per hand and in total, and an optional WheelGrab stops it at either end. The speed caps are saved.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private float maxRotatePerSecondPerHandDegrees per second one hand can contribute.
private float maxRotatePerSecondTotalDegrees per second all hands together can turn it.
private Pickup[] pickupsThe pickups players grab to turn the object.
private Dictionary<Interactor, Vector3> relativeGrabsEach holding hand's grab point in the rotating object's local space.
private Transform rotatingObjectThe transform that turns; defaults to this one.
private Vector3 rotationAxisLocal axis to turn around; defaults to up.
private WheelGrab wheelGrabOptional wheel whose Progress limits turning at 0 and 1.

Methods​

4 private and internal methods
MemberWhat it is
private void Awake()Defaults the rotating object to this transform and the axis to up, and hooks the pickups' interaction events.
private void Ended(Interactable interactable, Interactor interactor)Forgets the releasing hand and disables updates once no hand is holding.
private void Started(Interactable interactable, Interactor interactor)Remembers where the hand grabbed in the object's local space and enables updates.
private void Update()Turns the object by the summed signed angle each hand has moved, clamped by the per-hand and total caps and by the wheel's progress limits.