I’m currently building a countdown system that works in seconds (see image below), but I’d like to convert it into a clock format — for example, HOUR:MINUTE (HH:MM).
My long-term goal is to create a “Time of Day” system, where each real-time second represents one in-game minute (the exact ratio is still to be decided).
Do you have any idea on how to turn this simple countdown set in seconds into a clock with two separate digits - hours and minutes?
I’ve helped a few get this system together, there are a few things you will want to do:
Thing one is to have a separate values for Minutes and Hours. Time as one float is doable but requires more active math and is less performant. Also, you can make them both Integers, to further simplify, since you are measuring whole numbers.
Thing #2 is you set up your timer by event to add 1 to “Minutes” on a 1s timer. After you add 1 to “Minutes”, check if “Minutes >=60”. If true, set Minutes to 00 and add 1 (or ++) to Hours.
Then thing 3 is if hours was adjusted, you want to check if hours = 13 or 24 (depending on if you want international or AM/PM style). For international use (if Hours = 24, set Hours = 00) and for AM/PM use (if Hours = 13, set Hours = 1).
Lastly, use a Concatenate String node, and convert Hours to string for slot A, add a “:” to slot B, and convert Minutes to string for Slot C. Output that and convert string to Text and there you go!
Hope that helps! If you need more visual aids I can go slap some together.
Hi! Wow, thank you so much for that.
I would love to get some visual references if you don’t mind - especially to see how you set up two co-existing variables (for hours and minutes).
For your last point, I assume you are talking here about the part that goes in the widget to display the hour in the format HOUR:MINUTES?