24 Hour Game Clock (Per second compared to per tick)

1

Stats

576 visits, 721 views

Tools

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 2 Jun, 2021.

In this video I discuss how to make a 24 hour clock and the issue when using Tick vs Seconds. I also talk a little about modulus. This tutorial uses modulus or % in division. If you are not familiar with modulus I have tried to explain it below.

"7 % 2" would evaluate to 1, because 7 divided by 2 has a quotient of 3 and a remainder of 1, while "9 % 3" would evaluate to 0, because the division of 9 by 3 has a quotient of 3 and a remainder of 0

So in the code we use ClockSeconds%60 to see if we need to add 1 to the seconds variable. ClockSeconds%60 = 0 means we have a multiple of 60 (no remainder) so we add to seconds if ClockSeconds%60 is not = 0 then that means we don't have a number divisible by 60 (we have a remainder).

  • 0 Comments

Want to leave a comment? Login or Register an account!