Skip to main content

LerpingControlledFloatValue

A class in Root.Township, Alta.Utilities.

A float that eases toward a target over time and writes each step through a setter callback. A control value can temporarily take over the target. Call Update every frame.

Constructors​

MemberWhat it is
LerpingControlledFloatValue(Action<float> setValue)Creates a LerpingControlledFloatValue from setValue.

Fields​

8 private and internal fields
MemberWhat it is
private float controlValue the lerp heads to while controlled.
private Func<float> getTargetFunction giving the current target when not controlled.
private float initialValue at the start of the current lerp.
private bool isControlledTrue between SetControl and StopControl.
private float lerpSpeedDuration of a lerp in seconds, despite the name.
private float progressLerp progress from 0 to 1.
private Action<float> setValueCallback that receives each new value.
private float snapValueValue stored by a Snap made while controlled.

Properties​

MemberWhat it is
float Current { get; private set; }The current value, as last passed to the setter.
bool IsLerping { get; private set; }True while moving toward a target.

Events​

MemberWhat it is
event Action FinishedLerpRaised when a lerp reaches its target.

Methods​

MemberWhat it is
void Kill()Stops any lerp and holds the current value.
void Lerp(float target, float lerpSpeed)Starts moving toward a fixed target (with a duration in seconds) or toward a target read every frame.
void Lerp(Func<float> getTarget)Starts moving toward a fixed target (with a duration in seconds) or toward a target read every frame.
void SetControl(float control)Starts moving toward a control value, which overrides the normal target until StopControl.
void Snap(float newTarget)Jumps straight to a value. While controlled, it instead sets the target used after control ends.
void SnapIfNotLerping(float newTarget)Snaps only if no lerp is running.
void StopControl()Ends control and lerps from the current value back to the normal target.
void Update()Advances the lerp by the frame time and calls the setter.
protected float Lerp(float target)Starts moving toward a fixed target (with a duration in seconds) or toward a target read every frame.
1 private and internal method
MemberWhat it is
private float SnapValue()Returns the value saved by a Snap made while controlled, used as the target once control stops.

Used in​

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