Skip to main content

CaptainsWheel

A class in Root.Township, the global namespace.

A turnable wheel that adds up how far it has been turned into a running value, checked every LateUpdate. The angle is measured to the world origin in the wheel's local XY plane.

Constructors​

MemberWhat it is
CaptainsWheel()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

5 private and internal fields
MemberWhat it is
private float currentAngleAngle from last frame, in degrees.
private float directionSign or scale for the value change. Use -1 to reverse.
private float lengthPerRevolutionHow much the value changes per full turn.
private float valueBacking field for Value.
private FloatEvent valueChangedSerialized event raised with the new value.

Properties​

MemberWhat it is
float Value { get; }Running total of turns times lengthPerRevolution. Not clamped.

Events​

MemberWhat it is
event Action<float, float> ValueChangedRaised with the old and new value.

Methods​

3 private and internal methods
MemberWhat it is
private void LateUpdate()Runs UpdateValues each frame.
private void OnValueChanged(float newValue)Stores the new value and raises both the C# and serialized change events.
private void UpdateValues()Works out the angle turned since last frame and adds it to the value, scaled by length per revolution and direction.

Used in​

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