Working with Time in Unity


In this tutorial I explain how time.deltaTime works and how we can use it to build a stopwatch and a countdown timer.
+0:30 Creating a Text Field
+1:10 Adding a Custom Google Font
+1:40 Creating a Countdown Script
+2:45 Explaining time.deltaTime
+4:40 Creating a Stopwatch Script
+5:45 Using a UI button to start/stop timer
+7:05 Changing our buttons text on the fly




Xem thêm bài viết khác:


  1. This is really helpful. However, I haven't managed to stop the stopwatch once it reaches 0…:(….it goes on to -1, -2, -3….can anyone help me? I'm not a programmer, but I am trying to learn step by step.

  2. .. damn now how does one get this trnslated onto a Target game object…. (so if you hit hte target the timere starts, and if you defeated the target the timer stops)

  3. how do I make a gameobject appear after a certain time is passed? For example the StopWatch just reached 30s and then I want my boss to appear when that specific time is reached?

  4. Nice clear walk through, thanks for that.

    Got a comment for you though. I found this through the press start web site. I liked it , so clicked on your name to see what else you've gone over.
    However firefox threw up that warning message about possible attack site. Im assuming this is a false positive but thought you should be aware of it , as I can see how it might cost you some traffic.
    Unfortunately I couldn't find away to let you know privately, other than patreon.

  5. Wow…I think your Unity tutorial should be listed as a course on Unity Learn. Your videos are just way more easier to follow through and practical. Thanks a lot for AWESOME tutorials!!

  6. Great tutorial. Thank you. I'm using this for a lap timer and am stuck trying to get minutes working. The timer just increments so 1 minute 22 seconds is shown as "82.00". Any pointers on converting this into a min:sec:millisec format?

  7. Would this work (this is just a test not an actual script)

    Public bool time;

    Void update()
    If time == true()
    Then insert the stuff you did in update
    If timestart = 0;
    Time = false;
    If time == false
    Debug.Log("Timer is at 0")

    This took long to write cuz I'm on mobile but just asking if this would work for somthing to happen when timer runs out


  8. Wow. Liked and Subbed!

    Question, how can i edit it so that the countdown timer only begins once 2 objects (which i've tagged in unity) collide?

  9. how would i be able to add 1 second of time to my timer whenever the player collides and picks up a collectible?

  10. It was working perfectly but now the countdown timer counts down 2/2.5 times faster than actual seconds, know what could be wrong? Thanks.

  11. It's good but,It's notworking .if I create public void timeButton and use Onclick input Main camera when play mode time is stop in 0.00 and no can click nothing.

  12. Works like a charm. Out of all the tutorials I've watched this is the first one where I see the ? and : being used.

  13. hello, how to do for the enemy to have an AI, where he passes by plane at the top and launches bomb, and this one goes towards the player that are towers? thank you

  14. What a great video, I don't understand why you don't have more views and likes 😀
    Good job mate, simple and to the point

  15. Can u make a tutorial about what and when to use Time.Deltatime and the Time.FixedDelta time?

    Thanks 😀😁

  16. simple and interesting tutorial!, Might you consider a tutorial in which if a player or an object collides with another type of object or trigger, then It can be added/subtract time (e,g +/-10 seconds) to the respective timer?


Please enter your comment!
Please enter your name here