HoverPickup
A class in Root.Township, the global namespace.
Makes a pickup float back to a set spot when let go, like the menu and customization orbs. Works locally, or only on the server when networked.
- Listed in Global namespace: E to H
- Inherits or implements
MonoBehaviour - Derived types
ActionOrb,DelayedHoverPickup - Documented in Items, interaction and damage
Constructors
| Member | What it is |
|---|---|
HoverPickup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
protected bool isNetworked | Whether only the server moves it back. |
protected Pickup pickup | Backing field for Pickup. |
protected bool teleportToTargetOnRelease | Despite the name, true makes it fly back smoothly; false snaps it after the delay. |
13 private and internal fields
| Member | What it is |
|---|---|
private float acceleration | How fast the pickup accelerates while flying back. |
private Transform cachedParent | The pickup's original parent, restored on snap. |
private bool isAlwaysReturning | If true, the pickup's start pose is used as its return target when none was set. |
private bool isMaintainingParent | If true, the target is stored in the parent's local space and the pickup is re-parented on snap. |
private bool isPositionSet | True once a return target has been set. |
private float moveSpeed | Top speed while flying back. |
private Vector3 position | Return target position (local when isMaintainingParent). |
private Coroutine returning | The running return coroutine, if any. |
private float returnPositionThreshold | Squared distance at which the return counts as arrived and snaps. |
private Quaternion rotation | Return target rotation (local when isMaintainingParent). |
private float rotationLerpSpeed | How fast the rotation turns toward the target while returning, faster when close. |
private FauxRigidbody selectionOrbRigidbody | Faux rigidbody used to move the pickup while it returns. |
private float snapDelayInSeconds | Delay before snapping back when teleportToTargetOnRelease is off. |
Properties
| Member | What it is |
|---|---|
Pickup Pickup { get; } | The pickup being returned. |
Methods
| Member | What it is |
|---|---|
void SetTarget(Transform target) | Sets the spot to return to, from a transform or a position and rotation. |
void SetTarget(Vector3 position, Quaternion rotation) | Sets the spot to return to, from a transform or a position and rotation. |
void Snap() | Puts the pickup straight onto its spot and stops it. |
async void SnapWithDelay() | Snaps after the snap delay. |
protected virtual void Awake() | Hooks grab and release on the pickup. |
protected bool CanExecute() | True when not networked, or networked and on the server. |
protected virtual void HandleGrabbed(Interactable interactable, Interactor interactor) | Stops returning when grabbed. |
protected virtual void OnDestroy() | Stops all coroutines. |
protected virtual void OnReturning(Vector3 direction, float velocity) | Hook called each frame while flying back, with direction and speed. Does nothing by default. |
protected virtual void Start() | Remembers the parent and, if no target is set, uses the current position as the target. |
protected virtual void StartMovingBack(Interactable interactable, Interactor interactor) | On release, starts returning to the spot if one is set. |
protected void StopReturning() | Stops the return coroutine. |
2 private and internal methods
Used in
Members of other types that take, return or hold a HoverPickup: