Skip to main content

Lever

A class in Root.Township, the global namespace.

A physical lever Trigger: reads the handle's X rotation each physics step and is on while it sits inside its angle range.

Constructors​

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

Fields​

6 private and internal fields
MemberWhat it is
private float currentValueBacking field for Value.
private Transform handleTransform whose local X rotation is read as the lever angle.
private Rigidbody handleRigidbodyHandle rigidbody; nothing is read while it sleeps.
private bool isForcedOnNot used by this class.
private float rangeMaxAngle in degrees where Value reaches 1. Defaults to -40.
private float rangeMinAngle in degrees where Value is 0. Defaults to -60.

Properties​

MemberWhat it is
float Value { get; set; }Handle position as 0 to 1 across the angle range. Setting a new value raises ValueChanged.

Events​

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

Methods​

1 private and internal method
MemberWhat it is
private void FixedUpdate()While the handle is awake, maps its X angle to Value and sets the trigger on when it's between the range limits.

Used in​

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