Skip to main content

WheelGrab

A class in Root.Township, the global namespace.

Turns a wheel's rotation into a saved 0 to 1 progress value. Runs every frame on both sides; progress, rate and direction are saved.

Constructors​

MemberWhat it is
WheelGrab()Creates a WheelGrab with default values.

Fields​

5 private and internal fields
MemberWhat it is
private float currentAngleWheel angle last frame, in degrees, used to measure the change.
private float directionMultiplier on the progress change; a negative value makes the opposite turn add progress. Saved.
private float progressBacking field for Progress.
private FloatEvent progressChangedSerialized event fired with the new progress, and on load.
private float progressPerRevolutionProgress gained per full turn. Saved.

Properties​

MemberWhat it is
float Progress { get; }Current progress from 0 to 1. Saved.

Events​

MemberWhat it is
event Action<float, float> ProgressChangedRaised with the old and new progress when it changes.

Methods​

MemberWhat it is
void SetProgress(float newValue)Sets progress and fires both ProgressChanged and the serialized progressChanged event.
2 private and internal methods
MemberWhat it is
private void LateUpdate()Calls UpdateProgress every frame.
private void UpdateProgress()Measures how far the wheel turned since last frame and adds it to progress, clamped to 0 to 1.

Used in​

Members of other types that take, return or hold a WheelGrab: