I’m working on a time-attack level, and i have already set up a basic countdown timer. The countdown shows in the HUD as “120” as it is set to 2 minutes, what i want to do is get the timer to show as “02:00:000” instead. This is the BP setup of my timer.
I just created a timer for my project. I show the timer on the HUD using UMG. I wanted the format 0:00. It looks like you also want the milliseconds, but it would be the same process. Basically I set a variable for each digit. I give each variable the default value I want it to start at. The first digit on the right counts down, causing the next digit to countdown etc. It may not be the most effective method, but may be option.
A demo of my timer
I kind of managed to do it, however, i ran into another issue. Once the milliseconds or seconds reach 0, they don’t start over to count for the next second/minute respectively. I’ve tried Do N and While Loop to try and fix it, but Do N does nothing and While loop crashes the engine. here’s my setup and a screenshot of the issue.
Note that the millisecond stopped counting down when it reached 0 of the 59th second
I am not sure this helps, but here is what I did. When a digit reaches zero it adds the appropriate number and then counts down again. So the last digit adds 9 and the second digit from the left adds 5 causing it to reset to 59 seconds. It continues to do this until the minute digit reaches zero. I also set a boolean variable called “time low” when the player only has a minute left. Then I cause the player to die when all the digits are zero.
There it is! Thank you!
also, might want to add a delay before adding seconds and milliseconds, 1 and 0.001 respectively.
You’ve already got a “> 0” check in your events. Currently, you only reduce the value if the check is true. You’ll want to reset the variables to their maximum values if the check returns false.
Why this crazy set up if you could just use Timespan type?
Blueprint seems to missing that but, in C++ this type has also ToString function with formating
I want the timer like 00:02:23 to count down to 00:00:00, with your pictures I can get 00:02:23,but it can not count down to 00:00:00.I need your help,I am new UE4 Thank you