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.
- Listed in Players and characters
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
ItemLevitator() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
8 private and internal fields
| Member | What it is |
|---|---|
private IUnityUpdateMethod animateHover | Handle for the registered hover update. |
private Vector3 hoverPosition | Centre point of the hover. |
private float hoverSpeed | Speed of the bob (default 0.5). |
private float hoverStrength | Height of the bob (default 0.03). |
private Pickup pickup | The pickup on this object. |
private float randomStartOffset | Random phase so items do not bob in step. |
private Vector3 velocity | Drift velocity left over from when the item was released. |
private float velocityDrag | How fast the drift slows (default 1). |
Events
| Member | What it is |
|---|---|
event RefBoolDelegate CheckHover | Raised with a ref bool before hovering starts; any handler can set it false to stop the hover. |
Methods
| Member | What it is |
|---|---|
void StopHovering() | Stops the hover update. It does not turn kinematic back off. |
9 private and internal methods
| Member | What 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: