Skip to main content

BouncingValue

A class in Root.Township, the global namespace.

Server component that moves a value back and forth between 0 and 1 and reports it through an event every fixed update.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private bool isIncreasingCurrent direction.
private float oneWayDurationSeconds to go from 0 to 1 (5 by default).
private IUnityUpdateMethod updateValueHandle for the registered update.
private float valueCurrent value, 0 to 1.
private FloatUnityEvent valueUpdatedEvent fired with the value each step.

Methods​

3 private and internal methods
MemberWhat it is
private void OnDestroy()Deregisters the update.
private void Start()Server: registers UpdateValue on the fixed update module.
private void UpdateValue()Steps the value up or down, reverses at 0 and 1, and invokes valueUpdated.