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.
- Listed in Global namespace: P
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
PullingHandle() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
12 private and internal fields
| Member | What it is |
|---|---|
private Dictionary<Interactor, Vector3> lastPositions | Last grip position of each hand holding the handle. |
private Vector3 maxValue | Upper corner of the allowed local position box. |
private Vector3 minValue | Lower corner of the allowed local position box. |
private bool orientatesToHand | When true, a single holding hand also turns the pickup to match its grip, and rotation is synced. |
private Vector3 orientationAxis | Local axis the handle rotates around. |
private Pickup pickup | Pickup the player grabs. |
private bool rotatesAroundAxis | When true, hand movement also rotates the target around orientationAxis. |
private Vector3 syncedPosition | Position buffer used while serializing the release. |
private Quaternion syncedRotation | Rotation buffer used while serializing the release. |
private MethodSync syncReleasePosition | Method sync used to send the release position. |
private Transform target | Transform that is moved by the hands. |
private IUnityUpdateMethod trackHands | Handle for the registered tracking update. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Sets up the method sync that sends the release position. |
6 private and internal methods
| Member | What 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. |