Hi,

I have made a game but I want to make it time-based and I don’t know how to do that.

Example:
Game is supposed to be 10 minutes long and as the player progresses through the game, the time should decrease until it reaches 0 (which means game over).

Also, my game requires to pick up certain items which increase the time for the player.
Example: The time to complete the game is 10 mins. When the player is down to the 5th minute, he picks up a pencil. This items increases his time to 7 mins. How do I do that?

Please help. Thanks a lot.

Time.DeltaTime is your friend here. just make a timer that decreases by Time.DeltaTime that is making a var that starts at 10(minutes) or 600(seconds) then decreases it each frame in Update().

in the timer script just make a function that adds to the timer, this will get called when the player revives and item.

Displaying the time as Min:Sec IS little more tricky, but still easy in the grand scheme of things. ToMinutes

float minutes = Mathf.Floor(timer / 60).ToString("00");
float seconds = (timer % 60).ToString("00);

when the timer reaches zero use a Quit Function or a game over function.
now there other questions like this.

and about 20 others in the Related Questions

Have a variable called timeLeft set to 600 (for 10 mins). In Update just subtract Time.deltaTime from it. To add time, just add the amount of seconds to it.