SimpleNetworkedPivot
A class in Root.Township, the global namespace.
Syncs one rotation axis of a hinged part (a pivot driven by a pickup) from the server to clients while nobody is holding it. Both sides: the server writes the angle, clients ease towards it.
- Listed in Global namespace: S
- Inherits or implements
NetworkEntityBehaviour,INetworkSerialized
Constructors
| Member | What it is |
|---|---|
SimpleNetworkedPivot() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static AccumulativeAverageCount prepareForWriteTimer | Static timing stats for PrepareForWrite across all pivots. |
static AccumulativeAverageCount serializeTimer | Static timing stats for Serialize across all pivots. |
10 private and internal fields
| Member | What it is |
|---|---|
private Vector3 axis | Local rotation axis (normalized) that is synced. |
private float lerpSpeed | Fraction of the remaining angle closed each fixed update on clients. |
private float maxValue | Highest angle in degrees the sync range covers. |
private float minValue | Lowest angle in degrees the sync range covers. |
private float precision | Angle precision used for compression and the at-target check. |
private Pickup targetPickup | The pickup whose held state decides when the angle is synced. |
private float targetRotation | Last angle written by the server or read by the client. |
private Transform targetTransform | The transform whose local rotation is synced. |
private IUnityUpdateMethod update | Handle of the registered client easing update, if running. |
private static UpdateModule updateModule | Fixed-update module the easing update runs in. |
Properties
3 private and internal properties
| Member | What it is |
|---|---|
private int Alta.Networking.INetworkSerialized.MaximumBits { get; } | Bits needed for the held flag plus the angle at the set range and precision. |
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.PrepareForWriteTimer { get; } | Shared timing stats for PrepareForWrite. |
private AccumulativeAverageCount Alta.Networking.INetworkSerialized.SerializeTimer { get; } | Shared timing stats for Serialize. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Client: hooks the pickup's interaction start and scene destroy so the easing update stops. |
7 private and internal methods
| Member | What it is |
|---|---|
private void FinishSerialization(Interactable interactable, Interactor interactor) | Client: stops the easing update when someone starts interacting with the pickup. |
private bool IsAtPosition(float currentRotation) | True when the given angle is within precision of the target angle. |
private void OnDestroy() | Client: removes the easing update. |
private bool Alta.Networking.INetworkSerialized.PrepareForWrite(bool isWriteFull) | Asks to send only when the pickup is not held and its rigidbody is awake. |
private void SceneDestroy(NetworkEntity entity, bool isUnload) | Removes the easing update when the entity is destroyed by the scene. |
private void Alta.Networking.INetworkSerialized.Serialize(Stream stream, bool isWriteFull) | Writes whether the pickup is held and, if not, the angle on axis. Clients snap on full reads and ease otherwise. |
private void UpdateRemote() | Client: eases the transform towards the target angle and stops once there and the rigidbody sleeps. |