RopeGrab
A class in Root.Township, the global namespace.
A grab handle on a rope belt (rope pulls, lifts): pulling the handle turns the belt, and the belt's turn is tracked as progress 0 to 1 along the rope's length. Progress is saved and synced from the server.
- Listed in Global namespace: Q to R
- Inherits or implements
NetworkEntityBehaviour,ISavable<RopeGrabSaveData>,ISavableSave<RopeGrabSaveData>,ISavableSaveBase - Derived types
RopeGrabSaveData - Documented in Items, interaction and damage
Constructors
| Member | What it is |
|---|---|
RopeGrab() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
25 private and internal fields
| Member | What it is |
|---|---|
private float currentProgress | Backing field for Progress. |
private Interactor interactor | Interactor holding the handle, or null. |
private float interactY | Handle's height along the rope, clamped to yMinimum and yMaximum. |
private bool isGrabClamped | If true, the hand point is pushed back when progress hits an end. |
private bool isInfinite | If true, progress isn't clamped at all. |
private bool isLooping | If true, progress isn't clamped; there is no wrap-around code. |
private bool isSyncing | True while blending to the server's progress. |
private float lastBeltRotation | Belt rotation last frame, used to measure movement. |
private float length | Rope length in metres that maps to progress 0 to 1. Saved. |
private float lerpSpeed | Speed of the blend to synced progress. |
private float maximumForce | Largest torque the hand can put on the belt. |
private float maximumForceDistance | Hand movement per frame that gives full torque. |
private float maximumForcePerSecond | How fast the torque can change. |
private float maximumSlidePerSecond | Serialized but not read by this class. |
private FloatEvent progressChanged | Float event invoked with the progress when it changes. |
private RopeBelt ropeBelt | The rope belt that moves with the handle. |
private Motor ropeBeltMotor | Serialized but not read by this class. |
private Pickup ropeGrab | The pickup players grab. |
private Interactable ropeLength | The rope's interactable; grabs on it go to the handle and it's the handle's parent. |
private float syncedProgress | Progress last received from the server. |
private MethodSyncStruct<bool> syncProgress | Method sync for progress. |
private IUnityUpdateMethod updateTilStopped | Handle of the UpdateTilStopped update. |
private IUnityUpdateMethod updateWithoutIk | Handle of the per-frame update for holders without player IK. |
private float yMaximum | Highest local position of the handle on the rope. |
private float yMinimum | Lowest local position of the handle on the rope. |
Properties
| Member | What it is |
|---|---|
float Progress { get; } | Current progress along the rope, 0 to 1 (can leave that range when infinite or looping). |
Events
| Member | What it is |
|---|---|
event Action<float, float> ProgressChanged | Raised with the old and new progress whenever it changes. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Forwards rope grabs to the handle, hooks grab start and end, raises the starting progress and creates the sync. |
override void OnConnected(Player player) | Sends the current progress to a joining player, snapping. |
void SetProgress(float value) | Sets progress directly and raises the events (old value reported as 0). |
11 private and internal methods
| Member | What it is |
|---|---|
private void CheckClamp() | Keeps progress within 0 to 1 unless infinite or looping; with isGrabClamped it also moves the hand point back by the overshoot. |
private void IkUpdated() | Runs UpdatePosition before the holding player's IK each frame (or every Update for non-player holders). |
private void InteractionEnded(Interactable interactable, Interactor interactor) | Stops following the hand, keeps updating until the belt stops, and re-parents the handle to the rope. |
private void InteractionStarted(Interactable interactable, Interactor interactor) | Starts following the grabbing hand, cancelling any sync blend in progress. |
private void OnDestroy() | Removes the update. |
private void OnDrawGizmosSelected() | Draws the handle's vertical travel range in the editor. |
private void OnProgressChanged(float oldProgress, float newProgress) | Invokes the progressChanged Unity event and the ProgressChanged C# event. |
private void OnValidate() | Raises the progress events in the editor so linked objects preview the value. |
private void SyncProgress(IPlayer player, Stream stream, bool isSnapping) | Syncs progress. Clients snap when told to, otherwise blend towards it after the belt stops. |
private void UpdatePosition(bool isStartingGrab) | Pushes the belt with torque from the hand's movement, converts belt rotation into progress and places the handle. |
private void UpdateTilStopped() | Late update after letting go: blends to synced progress and, once the belt stops, ends and the server sends the final value. |
Used in
Members of other types that take, return or hold a RopeGrab: