Skip to main content

ItemLevitator

A class in Root.Township, Alta.Progression.Skills.

Makes a pickup float in place when it is let go: it drifts to a stop and then bobs up and down. Stops when picked up, docked or destroyed.

Constructors​

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

Fields​

8 private and internal fields
MemberWhat it is
private IUnityUpdateMethod animateHoverHandle for the registered hover update.
private Vector3 hoverPositionCentre point of the hover.
private float hoverSpeedSpeed of the bob (default 0.5).
private float hoverStrengthHeight of the bob (default 0.03).
private Pickup pickupThe pickup on this object.
private float randomStartOffsetRandom phase so items do not bob in step.
private Vector3 velocityDrift velocity left over from when the item was released.
private float velocityDragHow fast the drift slows (default 1).

Events​

MemberWhat it is
event RefBoolDelegate CheckHoverRaised with a ref bool before hovering starts; any handler can set it false to stop the hover.

Methods​

MemberWhat it is
void StopHovering()Stops the hover update. It does not turn kinematic back off.
9 private and internal methods
MemberWhat it is
private void AnimateHover()Late update: slows the pickup's drift to a stop, then bobs it on a sine wave.
private void CheckStartHovering(Interactable arg1, Interactor arg2)Starts hovering if every CheckHover handler allows it. Runs on start and when the pickup is let go.
private void EnsureNotDocked(ref bool isValid)CheckHover handler that blocks hovering while the pickup is docked.
private void EnsureNotInteractedWith(ref bool isValid)CheckHover handler that blocks hovering while the pickup is held.
private void Start()Hooks the pickup's grab, dock, release and destroy events and tries to start hovering.
private void StartHovering()Keeps the pickup's velocity, makes its rigidbody kinematic and starts the hover update.
private void StopHovering(NetworkEntity entity, bool isUnload)Stops the hover update. It does not turn kinematic back off.
private void StopHovering(Interactor interactor, Pickup pickup, PickupDock dock)Stops the hover update. It does not turn kinematic back off.
private void StopHovering(Interactable arg1, Interactor arg2)Stops the hover update. It does not turn kinematic back off.

Used in​

Members of other types that take, return or hold a ItemLevitator: