PullAway
A class in Root.Township, Alta.Mechanisms.
Lets a player pull an object a set distance by grabbing a fake interactable, then fires onPulled on the server (such as pulling a root out of the ground). The holding player's game decides when the pull counts.
- Listed in Items, inventory and logic
- Inherits or implements
NetworkEntityBehaviour - Documented in Other systems
Constructors
| Member | What it is |
|---|---|
PullAway() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
13 private and internal fields
| Member | What it is |
|---|---|
private Rigidbody actualRoot | Rigidbody moved with the hand, kinematic while held. |
private float distanceSquared | Squared distance from the pull origin that counts as pulled. |
private Interactable fakeInteractable | The interactable players grab. |
private Coroutine gripCoroutine | The running CheckGrip coroutine. |
private AnimationCurve hapticsPerDistanceRatio | Curve from pull progress to haptic strength. |
private float maxDistancePerSecond | Speed limit on how fast the object follows the hand; 0 for no limit. |
private PlayerEvent onPulled | Player event fired on the server when the object is pulled free. |
private Vector3 origin | Not used in this class. |
private float pulledHapticDuration | Haptic length when pulled free (default 0.5 seconds). |
private float pulledHapticStrength | Haptic strength when pulled free (default 0.4). |
private Vector3 pullOrigin | Local point the pull distance is measured from. |
private bool releaseOnPull | Makes the player let go once pulled free. |
private MethodSyncStruct<uint> syncPull | Method sync (SyncA) from client to server for a pull. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the pull sync. |
7 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Hooks the fake interactable's grab and release. |
private IEnumerator CheckGrip(Interactor interactor) (iterator) | Coroutine that moves the root after the hand; for the local player, gives haptics and fires or sends the pull once past the distance. |
private void ClearCoroutine() | Stops the running CheckGrip coroutine. |
private void EndTracking(Interactable interactable, Interactor interactor) | On release, stops tracking and makes the root non-kinematic again. |
private void OnDrawGizmosSelected() | Editor: draws the pull origin and the pull distance sphere. |
private void StartTracking(Interactable interactable, Interactor interactor) | On grab, starts CheckGrip for that interactor. |
private void SyncPull(IPlayer player, Stream stream, uint playerIdentifier) | Sends the pulling player's identifier; the server fires onPulled for that player. |