Race Information
Last updated
Last updated
You can access some information about the race from UnityEvents and from code.
The conditions for events to happen are self-explanatory. To subscribe to an event, click on the "+" button under it, drag and drop a game object with script that contains a method that you want to be called and select the method:
The "On Player Finished" event also return an integer that represent the position of the player among the racers. To pass this integer into your method (the method should accept an int), select method from the top of the popup window (under "Dynamic int").
You can also subscribe to these events from code.
Add a "using" directive for "Assets.VehicleController"
Get a reference to the "RaceManager" component.
Access the race manager object's event and call the "AddListener" method, passing a method into it.
Besides events, which give you substantial information about the race progress, you can also access some methods and fields to find out more information
RacerProgress is an object created for every vehicle that registered for participation in a race.
It contains the following information:
Method | Description |
---|---|
Property | Description |
---|---|
Field | Description |
---|---|
GetLeaderboard()
Returns a sorted (ordered by the progress counting the number of laps finished) List of type "RacerProgress".
StartCountdownTimeLeft
The amount of seconds (float type) left before a race will start.
WaitForOtherRacersTimeLeft
The amount of seconds (float type) left after the podium places have been taken before a race will end.
IsPlayer
Returns true if the racer is a player. A racer is a player if the "RaceParticipant" component's property "IsPlayer" is set to True.
RacerName
The name of the root game object of the vehicle.
RacerProgressNormalized
A percentage of the progress on the current lap. Doesn't get updated after the racer finishes the race.
LapsPassed
The amount of laps completed by the racer.Doesn't get updated after the racer finishes the race.
FinishedRace
Returns True if the amount of finished laps is higher than the amount of laps in a race.