ScrollWheel
A class in Root.Township, the global namespace.
A wheel the player spins by hand: it follows the hand around its axis, lets go if the hand moves too far off, and keeps spinning with drag after release. Runs locally on each client.
- Listed in Global namespace: S
- Inherits or implements
MonoBehaviour
Constructors
| Member | What it is |
|---|---|
ScrollWheel() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
12 private and internal fields
| Member | What it is |
|---|---|
private float angleFromUpToMiddle | Angle from up around the axis to the middle of the grab area. |
private float angularVelocity | Current spin speed in degrees per second. |
private float angularVelocityDrag | How fast the free spin slows, in degrees per second squared. |
private Transform cachedTransform | Cached own transform. |
private Interactable dummyPickup | The interactable the player grabs to turn the wheel. |
private UnityEvent finishedSpining | Event fired when the free spin stops. |
private Coroutine interactingCoroutine | The running hand-following coroutine. |
private float maxAngleToRelease | Dot product limit; when the hand is further from the grab area's middle than this, it's released. |
private float maxAngularVelocity | Highest spin speed kept on release. Default 100. |
private FloatEvent rotatedAngle | Float event fired with each rotation step in degrees. |
private Vector3 rotationAxis | Local axis the wheel turns around. Default forward. |
private Coroutine spiningCoroutine | The running free spin coroutine. |
Properties
1 private and internal property
Methods
8 private and internal methods
| Member | What it is |
|---|---|
private void ApplyRotation(float angle) | Turns the wheel by an angle around its axis and fires rotatedAngle with that angle. |
private void Awake() | Caches the transform and hooks the dummy pickup's interaction start and end. |
private void CleanInteractingCoroutine() | Stops the hand-following coroutine if running. |
private void FinishedInteract(Interactable interactable, Interactor interactor) | Stops following the hand and starts the free spin. |
private IEnumerator Interacting(Interactor interactor) (iterator) | Coroutine that turns the wheel with the hand each frame and force-releases a local hand that leaves the allowed area. |
private void OnDrawGizmosSelected() | Editor: draws the rotation axis. |
private IEnumerator Spin() (iterator) | Coroutine that keeps the wheel turning after release, slowed by angularVelocityDrag, then fires finishedSpining. |
private void StartedInteract(Interactable interactable, Interactor interactor) | Stops any spin and starts following the grabbing hand. |