MovePickup
A class in Root.Township, the global namespace.
An object that slides along one axis when players grab and pull its handles, like a heavy door or lift. The server works out the force from hand positions with a PID controller and syncs movement and speed.
- Listed in Global namespace: M to O
- Inherits or implements
NetworkEntityBehaviour,ISavable<MovePickupSaveData>,ISavableSave<MovePickupSaveData>,ISavableSaveBase,INetworkSerialized - Derived types
MovePickupSaveData - Documented in Items, interaction and damage
Constructors
| Member | What it is |
|---|---|
MovePickup() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static AccumulativeAverageCount prepareForWriteTimer | Shared timing stat for all MovePickups. |
static AccumulativeAverageCount serializeTimer | Shared timing stat for all MovePickups. |
20 private and internal fields
| Member | What it is |
|---|---|
private float bottomBounce | Share of speed reversed when it hits the bottom. |
private float[] forcePerHand | Maximum force by number of hands holding (1 to 4). |
private bool isDisabling | Not used. |
private float maxDistance | How far it can move along the axis. |
private float maxHandDistance | Cap on how much one hand's pull counts. |
private float maximumNegativeSpeed | Fastest speed moving back down the axis. |
private float maximumPositiveSpeed | Fastest speed moving up the axis. |
private float movement | Current distance from the start position. Saved. |
private Vector3 movementAxis | Local axis it moves along. Set to up if left at zero. |
private float negativeForce | Constant force pushing it back toward the start, like gravity. |
private Pickup[] pickups | Handle pickups whose grabs move it. |
private PidController pidController | PID controller that turns hand pull into force. |
private PidController.Setup pidSetup | PID gains for the controller. |
private Dictionary<Interactor, Vector3> relativeGrabs | Server: each holding hand and where it first grabbed, in local space. |
private Vector3 startingPosition | Local position at rest. |
private float syncMovement | Last movement value sent or received. |
private float syncVelocity | Last speed value sent or received. |
private float topBounce | Share of speed reversed when it hits the top. |
private IUnityUpdateMethod update | Fixed update registration. Removed once it rests at the bottom with no hands. |
private float velocity | Current speed along the axis. Saved. |
Properties
3 private and internal properties
| Member | What it is |
|---|---|
private int Alta.Networking.INetworkSerialized.MaximumBits { get; } | Always 32. |
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.PrepareForWriteTimer { get; } | Shared timing stat for PrepareForWrite. |
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.SerializeTimer { get; } | Shared timing stat for Serialize. |
Methods
10 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Stores the start position, creates the PID controller and hooks grab start and end on each handle pickup. |
private void Ended(Interactable interactable, Interactor interactor) | Forgets a hand that let go. |
private void OnDestroy() | Stops the fixed update. |
private void OnDrawGizmosSelected() | Draws the movement axis in the editor. |
private void OnValidate() | Pushes changed PID values to the running controller. |
private bool Alta.Networking.INetworkSerialized.PrepareForWrite(bool isWriteFull) | Returns true if movement or speed changed since the last sync. |
private void RunFixedUpdate() | Server: adds force from how far hands pulled along the axis. Both: applies the downward force, bounces at the ends and moves the object. |
private void Alta.Networking.INetworkSerialized.Serialize(Stream stream, bool isWriteFull) | Syncs movement and speed, or a single bit when both are zero. Client: applies them and starts updating. |
private void Started(Interactable interactable, Interactor interactor) | Records where a hand grabbed and starts updating. |
private void StartUpdate() | Registers the fixed update if it isn't running. |