Reputation: 105
As I'm new to the coding and unity3d I'm finding tough to set the lap timer for my racing game which is the multiplayer game.
Upvotes: 1
Views: 877
Reputation: 426
Well in terms of just code.
Time.time
Will give you the time (duh)
So you'd do something like the following
function Awake() {
startTime = Time.time;
}
function OnGUI () {
var currentLap = Time.time - startTime;
}
currentLap is the current time since the script started. So you could run the code in the "Awake()" method when the race starts. Then on screen display what the current lap time is.
Found a nice example from the Unity Developer Network that might be exactly what your looking for here
Upvotes: 1