<aside> <img src="/icons/reorder_gray.svg" alt="/icons/reorder_gray.svg" width="40px" />

Navigation

</aside>

🏠 Home Page

Getting Started

Architecture

Level System

Characters & Vehicles

Run Mechanics

World Objects

Boosters & Modifiers

Progression & Economy

UI

Save & Debugging

Modules

Publishing

Reference

💰 Monetization (Ads & IAP)

<aside> 💡 The run HUD is part of the UI Game page. RunHUD shows the speed, the distance, the progress and the fuel. ActiveBoosterHUD shows the timed boosters.

</aside>

Subsystems

page-game.png

RunHUD

GameController sets the values every frame while the character is launched. The values are live telemetry, so no animation is used.

Element Fields Description
Speedometer Speed Text, Speed Fill, Max Speed Kmh, Speed Fill Max The speed in km/h. The arc fills from 0 to Speed Fill Max while the speed goes from 0 to Max Speed Kmh.
Distance map Progress Fill, Player Marker, Player Progress Text, Record Marker, Distance Text A vertical bar. The bottom is the start and the top is the finish. The record marker shows the farthest distance reached on the level.
Fuel gauge Fuel Root, Fuel Fill, Fuel Sprite, Fuel Low Sprite, Fuel Low Share Visible only for a vehicle with an engine (MovementBehavior.HasFuel). The fill uses the low sprite below Fuel Low Share.

Methods called by GameController:

Method Description
SetSpeed(speed) Speed in m/s. The HUD converts it to km/h.
SetProgress(value01) Share of the level covered.
SetDistance(distance) Distance in meters.
SetFuel(behavior) Fuel gauge of the active behavior.
SetRecord(value01) Position of the record marker.

The level length used by the progress is the distance between the Start Point and the Finish Point along the start forward axis.

ActiveBoosterHUD

The component lives inside UI Game and implements IUIPageElement. It subscribes to BoosterController.OnBoosterActivated and OnBoosterDeactivated.

Field Description
Slots List of ActiveBoosterSlot. A timed booster uses the first free slot.

Instant boosters are not shown. When all slots are in use, extra boosters have no indicator. Add slots to the list to show more.

An ActiveBoosterSlot shows the booster icon and a radial timer.

Restart button

The Restart button of UIGame raises OnRestartPressed. GameController ends the run and returns to the start screen without the result page. See Run Result & Level Complete.

How to add an element to the HUD

  1. Add the UI. Add the element to the UI Game prefab.
  2. Add the field. Add a serialized reference and a setter method to RunHUD.
  3. Update the value. Call the setter from GameController.Update while the character is launched, or from an event.
public void SetBest(float distance)
{
    bestText.text = $"{Mathf.RoundToInt(distance)}m";
}