Displaying a digital countdown timer
As a game mechanic, countdown clocks are a popular feature in many games:
Figure 1.10: Countdown clock
This recipe, which will adapt the digital clock shown in the previous recipe, will show you how to display a digital countdown clock that will count down from a predetermined time to zero.
Getting ready
This recipe adapts to the previous one. So, make a copy of the project for the previous recipe and work on that copy.
For this recipe, we have prepared the CountdownTimer
script that you need in a folder named _Scripts
inside the 01_03
folder.
How to do it...
To create a digital countdown timer, follow these steps:
- Import the provided
_Scripts
folder. - In the Inspector panel, remove the scripted component, ClockDigital
,
from the Text-clock GameObject. You can do this by choosing Remove Component from the 3-dot options menu icon for this component in the Inspector panel. - In the Inspector panel...