Skip to main content

Class AnalogSpeedometer

A speedometer interface that visually simulates a traditional analog speedometer by rotating an arrow based on the current speed.

public class AnalogSpeedometer : Speedometer

Inheritance​

Inherited Members​

Remarks​

This speedometer is designed with the assumption that all instances in the scene will receive speed updates from a single actor only (typically the player). If multiple actors in the scene send ActorSpeedMessage events, it will cause conflicts and unreliable readings, as all Speedometer instances will respond to messages from every actor indiscriminately. Ensure only one actor broadcasts speed updates per scene.

Methods​

SetProgress(float)​

Updates the speedometer visual and triggers the OnValueChanged event.

public void SetProgress(float value)

Parameters​

NameTypeDescription
valuefloatNormalized speed value between 0 and 1.

SetRawSpeed(float)​

Sets the current raw speed sample (in meters per second) for this speedometer.

public override void SetRawSpeed(float rawSpeed)

Parameters​

NameTypeDescription
rawSpeedfloatThe actor's speed in meters per second (m/s), typically the magnitude of its velocity.

Remarks​

Implementations should convert to the configured display unit, multiply by speedDisplayScale, and take the absolute value before updating any visuals, Call this whenever a new speed value is available (e.g., per FixedUpdate). Keep implementations allocation-free and fast; this may be invoked frequently. A common pattern is:

var converted = Mathf.Abs(ConvertRawSpeed(Mathf.Max(0f, rawSpeed), speedDisplayUnit) * speedDisplayScale); // Update UI/needle/text/etc. with 'converted'