TelescopicPickup
A class in Root.Township, the global namespace.
A pickup that extends or shortens along an axis as the player pulls their two hands apart, like a spyglass. The length is worked out on the holder's side in the IK update.
- Listed in Global namespace: T to X
- Inherits or implements
NetworkEntityBehaviour - Documented in Items, interaction and damage
Constructors
| Member | What it is |
|---|---|
TelescopicPickup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
14 private and internal fields
| Member | What it is |
|---|---|
private Vector3 axis | Local direction the moving part slides along. |
private CenterOfMassSetter centerOfMass | Centre of mass setter averaged between the hands while held. |
private PlayerCharacter character | The player holding it with both hands, while they do. |
private float currentLength | Current distance of the moving part along axis. |
private GrabPoint grabLeft | Grab point held by the left hand. |
private GrabPoint grabRight | Grab point held by the right hand. |
private float lengthOffset | Difference between the length and the hand distance when the second hand grabbed. |
private float maximumLength | Longest length. |
private float minimumLength | Shortest length. |
private float moveSpeed | Fastest the length can change, per second. |
private Transform movingPart | The part that slides in and out. |
private FloatEvent progressSet | Event fired with the new progress whenever it changes. |
private float syncPrecision | Precision used when syncing progress. |
private MethodSync syncProgress | Message carrying the progress. |
Properties
| Member | What it is |
|---|---|
Pickup Pickup { get; } | This entity's main pickup. |
float Progress { get; private set; } | How far extended it is, 0 at minimumLength to 1 at maximumLength. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the progress sync message. |
override void OnConnected(Player player) | Sends the current progress to a player who connects. |
5 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Reads the starting length and progress, hooks grab and release, and disables updates. |
private void IkUpdated() | Before each IK update, sets the length from the distance between the hands (clamped and speed-limited), moves the hand anchors and reports the new Progress. |
private void InteractionEnded(Interactable interactable, Interactor interactor) | Clears the released hand's grab point and stops the IK hook. |
private void InteractionStarted(Pickup interactable, Interactor interactor) | Records which grab point each hand took; once both hands hold different points, hooks the holder's IK update and stores the length offset. |
private void Sync(IPlayer player, Stream stream) | Serializes Progress; a client applies it to the moving part. As decompiled it uses InverseLerp for the length, so remote lengths are probably off. |