Skip to main content

Class ActorsSpeedTracker

Measures the actor's signed forward speed by projecting its velocity onto the transform forward axis, and exposes the result in m/s, mph, and km/h.

[DisallowMultipleComponent]
public class ActorsSpeedTracker : MonoBehaviour, ISpeedTracker, IDataLoggable

Inheritance​

Derived​

CarControllerSpeedMeasure

Implements​

Remarks​

At startup the component selects the most accurate velocity source available on the same GameObject — Rigidbody, then CharacterController, then a position-delta fallback — so the same component works on the physics-based vehicle pawn, the CharacterController-based pedestrian pawn, and any future actor that has neither.

Speed is projected onto transform.forward so that reversing produces a negative value — important for the AI gear-change timer in PlayerCarDriver and for correct speedometer readings during reverse manoeuvres.

Properties​

Speed​

The current forward speed of the actor in meters per second.

public float Speed { get; }

Property Value​

float

SpeedKPH​

The current forward speed of the actor in kilometers per hour.

public float SpeedKPH { get; }

Property Value​

float

SpeedMPH​

The current forward speed of the actor in miles per hour.

public float SpeedMPH { get; }

Property Value​

float

Methods​

Collect()​

Collects the current forward speed for data logging.

public DataLog Collect()

Returns​

DataLog — A SpeedDataLog containing the current forward speed.