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.
use Invoke() or InvokeRepeating() for simple timers in Unity. this is the most asked question on the site. search for 10,000s of questions on timers, invoke, yield, time.deltatime etc etc. unityGEMS.com for many good beginner articles on it
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
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.
Hey! I know this solution use this transform.rotation = Quaternion.AngleAxis(angle -90f, Vector3.forward); if doesn't work change -90f to -180
use Invoke() or InvokeRepeating() for simple timers in Unity. this is the most asked question on the site. search for 10,000s of questions on timers, invoke, yield, time.deltatime etc etc. unityGEMS.com for many good beginner articles on it
– Fattie