VerticalFlyingController
A class in Root.Township, the global namespace.
Makes a flying object bob up and down over the ground. The server picks random target heights and both sides push the rigidbody's vertical velocity toward the target; it stops while the optional pickup is held or docked.
- Listed in Global namespace: T to X
- Inherits or implements
NetworkEntityBehaviour
Constructors
| Member | What it is |
|---|---|
VerticalFlyingController() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private float acceleration | Vertical acceleration per second toward the target. |
private Vector3 cachedPosition | Declared but never used. |
private bool isHeldOrDocked | Whether the pickup is held or docked right now. |
private float maxVelocity | Cap on vertical speed. |
private AnimationCurve modulator | Curve sampled with a random value to size each move, as a fraction of movementAmplitude. |
private float movementAmplitude | Highest target height above the ground. |
private float movingTowards | Current target height above the ground. Only the server picks it; it isn't synced here. |
private float nextSign | Direction of the next move. Flips each time a target is picked. |
private Pickup pickup | Optional pickup. While it's held or docked the movement stops. |
private Rigidbody rigidbody | The rigidbody whose vertical velocity is driven. |
private IUnityUpdateMethod updatePosition | Handle for the registered fixed-update method. |
private bool usesNegativeValuesOnModulator | When true, the modulator is sampled with a signed input (-1 to 1) instead of 0 to 1. |
private Walker walker | The Walker that gives DistanceToGround. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Registers the server or client fixed-update method and hooks the pickup's grab and dock events. |
7 private and internal methods
| Member | What it is |
|---|---|
private void DockedChanged(Interactor interactor, Pickup arg2, PickupDock arg3) | Dock and undock handler for the pickup; calls UpdateControlled. |
private void GetNewPosition() | Server: picks the next target height, alternating up and down by an amount from modulator, kept between 0 and movementAmplitude. |
private void InteractionChanged(Interactable interactable, Interactor interactor) | Grab and release handler for the pickup; calls UpdateControlled. |
private void OnDestroy() | Deregisters the update method. |
private void ServerUpdatePosition() | Server fixed update: picks a new target once within 5 cm of the current one, then calls UpdatePosition. |
private void UpdateControlled(Interactor interactor) | Stops the movement while the pickup is held or docked and starts it again once it's free. |
private void UpdatePosition() | Accelerates the rigidbody's vertical velocity toward the target height, capped at maxVelocity. |