A Digital Clock or how to add a value to the variable

Evening, i need a digital clock in my project. For that, i made a 3d widget, inside the widget i have 3 text boxes

  1. hours 2) “:” 3) minutes

1&3 are set up as variables inside the widget.

I thought about making a timeline for the seconds so:

after 60 seconds passed, add 1 to “minutes” variable
if “minutes” are greater then 59, add 1 to “hours” and reset “minutes” & play the timeline from start

sounds pretty legit i guess, but the big question for me now is, how do perform that and finaly how to update the text for both minutes and hours :S ?

You’ll likely make use of the % modulo operator, gets remainder of a division. So seconds = elapsedSeconds%60, minutes = (Floor(elapsedSeconds/60))%60 hours = (Floor(ElapsedSeconds/3600))%24 (If you want a 12 hour clock just add on conversion logic for a 24 hour day to be AM/PM)

Also, check out Rama’s plugins (39) Rama's Extra Blueprint Nodes for You as a Plugin, No C++ Required! - Blueprint - Epic Developer Community Forums!
There’s a time/date system in there.

Thx for the answer, i got something working over here, it just needs some small additions to make, but now im realy lost. I got the hours/minutes/seconds to work, the only thing to know is how to reset the variable to 0 in my blueprint setup. But i will check this plugin out.

Edit: Made a better resolution for the picture

2nd Edit: Ok completly forgot the branch option, reset now also works

This leads to one last question, and this i realy dont know how to do this, since the timer adds 1, the 0 on the clock, like
“12: 1: 8” gets lost, any way to add this zero to numbers from 1-9 ? :S

I would probably use something more like this:

It counts everything up by one second intervals and once your seconds reach 60, it adds a minute and sets your seconds back to 0. Then does the same if you hit 60 minutes (and you can add the same kind of check after the hours when it reaches 12 or 24 if you want.) This setup needs 3 variables for seconds, minutes and hours and a looping timeline with a length of 1 second and an event track with an event at the 1 second mark. You could also have your widget use only one text object and use the append node for strings to combine the results and just convert it to text.

And for adding zeros into your single digit numbers, you can still use the append node and select string when the variable is < 10.

Holy moly, thats nice man, thank you so much :DD, but pls forgive me for the question, where do i have to connect “cast to widget” part then ? :S

i duplicated my widget and blueprint for your version, and made just one text with variable.

You can put your “cast to widget > set text” on the “then 1” in the sequence node, where the “print string” is on my graph.
Then you can just drag the string into the text pin and it should automatically create a convert string to text node.

Hm duno, not working :S, its late and im tired so maybe thats why im not getting this work correctly :stuck_out_tongue_winking_eye:


Im rly sorry for the trouble man, i appreciate the time you waste on me :<

There’s 2 things it could be I guess.

One is that you forgot to put an event on the timeline at the 1 second mark and set the timeline length to 1 sec exactly. (Or your event is at something like 1.0232345 seconds, which is outside the range of the 1.0 second loop so it never triggers)

Or the other is that your cast doesn’t work, but I don’t know how that’s set up for you, so you can just test that by putting a print string at the “cast failed” with some sort of error message. (But if it worked before it’s unlikely it’s not working now.)

Well, the good message is, its working now, it hade to use the update and/or finished output in the timeline the let it fire.
The bad new is, even if the length it exactly 1 second, its some ms faster then it should be -.-"

What ever man, thank you soooo much for helping, i really appreciate it !

Edit: I take everything back, its working to 100% now like i want ! I dont know why and i actually dont want to explain it because its long long story :stuck_out_tongue:

Again, thx my friend. Problem solved, it looks much cleaner now without 50 nodes lol :smiley: