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
RaceTimingManagerexisting in the scene. - A
CompetitorFocusManagerexisting 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.
- Select your
RaceTimingManagerin the current scene. - In the Inspector, check Enable Delta Bar.
- 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.
Setup from Prefab (Recommended)
- Ensure you have a standard Unity Canvas in your scene.
- Navigate to
Assets/SlowToastRacing/RaceTiming/UI/Prefabs/ - Drag the
DeltaBarUIprefab as a child of your Canvas. - Position using the Rect Transform on the root object.
Manual Setup (Custom UI)
To build the Delta Bar yourself:
- Create a
UI -> ImagenamedDeltaBarFill. Set its Image Type to Filled and the Fill Method to Horizontal. - Create a
UI -> TextMeshPro - TextnamedDeltaText. - Create an empty GameObject named
CustomDeltaBarand add theDeltaBarUIcomponent. - Assign the Image to Delta Bar Image and the Text to Delta Text.
- Configure the colours in the Inspector:
- Faster Color (default Green)
- Slower Color (default Red)
- 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:
SetReferenceLapis onLapTimer, notRaceTimingManager. The second parameter must be aMicroSectorLapRecord(a fixed-size array of elapsed timestamps at each micro-sector boundary), not aLapobject.