Race Timer for Puzzle Game
I just started with Unity so I am completely new to this, I am trying to create a Countdown Timer for my puzzle game where once the timer counts down to 0 and you haven't completed the puzzle then you lose. I tried searching online but so far I've only found scrips for creating a countdown timer displayed text but not necessarily ending the game.
Any help?
Answer by Alderin · Jul 18, 2017 at 06:06 PM
I'm pretty new here, too, but my plan for a similar system (and research suggests) that having the counter run in a GameManager object that also handles the Game State (Menu, Running, GameOver, etc), is where to put it. Using Counter -= Time.deltaTime will give you a countdown in the Update function. You'll probably want to use clamping tricks to trim the numbers after the decimal for display, but the tutorials you mentioned probably covered that already.
Then all you need to do is switch your GameState to Game Over when the counter<0, and call whatever Game Over effects you need, such as a Scene Switch or show a hidden UI element.
I hope this helps.
Your answer
![](https://koobas.hobune.stream/wayback/20220612125442im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Change button position using script 2 Answers
Opacity object 1 Answer
How do I add my Timer to my Score system in C# ? 0 Answers
How can i run a script with a single key press? 1 Answer
How do you create a main menu? 1 Answer