Skip to content

UI Setup: DeltaBarUI

The DeltaBarUI overlay provides real-time feedback on whether the focused driver is currently faster or slower than a reference lap (usually their own personal best, or the session best).

Prerequisites

  • A RaceTimingManager existing in the scene.
  • A CompetitorFocusManager existing in the scene.
  • Track markers must be configured.
  • Delta Bar tracking must be enabled on the RaceTimingManager.

Enabling Delta Calculations

By default, calculating live deltas is disabled to save performance.

  1. Select your RaceTimingManager in the current scene.
  2. In the Inspector, check Enable Delta Bar.
  3. Configure Max Delta (default 9.999s) and Micro Sectors Per Sector (default 10). Higher micro-sectors means smoother bar updates, but slightly more memory overhead.
  1. Ensure you have a standard Unity Canvas in your scene.
  2. Navigate to Assets/SlowToastRacing/RaceTiming/UI/Prefabs/
  3. Drag the DeltaBarUI prefab as a child of your Canvas.
  4. Position using the Rect Transform on the root object.

Manual Setup (Custom UI)

To build the Delta Bar yourself:

  1. Create a UI -> Image named DeltaBarFill. Set its Image Type to Filled and the Fill Method to Horizontal.
  2. Create a UI -> TextMeshPro - Text named DeltaText.
  3. Create an empty GameObject named CustomDeltaBar and add the DeltaBarUI component.
  4. Assign the Image to Delta Bar Image and the Text to Delta Text.
  5. Configure the colours in the Inspector:
  6. Faster Color (default Green)
  7. Slower Color (default Red)
  8. Neutral Color (default White)

Setting the Reference Lap

The Delta Bar needs a lap to compare against. The underlying Core engine will usually automatically handle this when a driver completes their first valid lap, but you can override it if you want to force them to race a specific "Ghost" lap:

// Manually set Car 5's reference lap using a MicroSectorLapRecord
var lapTimer = RaceTimingManager.Instance.LapTimer;
MicroSectorLapRecord ghostRecord = new MicroSectorLapRecord(ghostTimestamps);
lapTimer.SetReferenceLap(5, ghostRecord);

Note: SetReferenceLap is on LapTimer, not RaceTimingManager. The second parameter must be a MicroSectorLapRecord (a fixed-size array of elapsed timestamps at each micro-sector boundary), not a Lap object.