Skip to main content

PullingHandle

A class in Root.Township, the global namespace.

A handle that follows the hands holding it inside a box of allowed local positions, and can twist around an axis. Syncs its final position to everyone when released.

Constructors​

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

Fields​

12 private and internal fields
MemberWhat it is
private Dictionary<Interactor, Vector3> lastPositionsLast grip position of each hand holding the handle.
private Vector3 maxValueUpper corner of the allowed local position box.
private Vector3 minValueLower corner of the allowed local position box.
private bool orientatesToHandWhen true, a single holding hand also turns the pickup to match its grip, and rotation is synced.
private Vector3 orientationAxisLocal axis the handle rotates around.
private Pickup pickupPickup the player grabs.
private bool rotatesAroundAxisWhen true, hand movement also rotates the target around orientationAxis.
private Vector3 syncedPositionPosition buffer used while serializing the release.
private Quaternion syncedRotationRotation buffer used while serializing the release.
private MethodSync syncReleasePositionMethod sync used to send the release position.
private Transform targetTransform that is moved by the hands.
private IUnityUpdateMethod trackHandsHandle for the registered tracking update.

Methods​

MemberWhat it is
override void Initialize()Sets up the method sync that sends the release position.
6 private and internal methods
MemberWhat it is
private void Awake()Hooks the pickup's interaction start and end to start and stop hand tracking.
private void OnDestroy()Deregisters the hand-tracking update.
private void StartTrack(Interactable interactable, Interactor interactor)Records the new hand's grip position and starts the tracking update if needed.
private void StopTrack(Interactable interactable, Interactor interactor)When the last hand lets go, stops tracking, sends the release position if this was the local player, and makes the pickup kinematic.
private void SyncReleasePosition(IPlayer player, Stream stream)Writes or reads the target's local position (and rotation if it orients to hand). The server relays it to the chunk.
private void TrackHands()Moves the target by how far the hands moved, clamped to minValue/maxValue, and rotates it around the axis.