How to create a UMG number counter?

I fiddled around with a end level widget screen, adding a number, binding that to a function and using an array to add numbers to the assigned text (counting from 0- max number) - displayed on the widget.

Though, it seems the array is too fast, always displaying the last number of the entire count. I read somewhere that i can setup a custom array function (Delayed ForEachLoop), but basically i do not want to touch the default functions. Is there another way?

Any suggestions how to create a widget based text counter, which counts level stats on the spot?

Hey unit23, you’re on the right track…not sure why you are using an array though. You can have your text bound to a function that gets a variable value from the widget, or another blueprint (gamestate/gamemode I recommend). You should set the value of the variable elsewhere, i.e. from a takeDamage function or playerLifeTotal function. You can not put delays in functions in UE4, only in custom events…so if you want your text to change based on time or an event, then you need to make a custom event/function that triggers elsewhere, and then get the value of that variable in your widget.

It’s even advised not to use the bind functions (they will fire every frame), and instead make a custom event/function that fires whenever you want to change the text…definitely get it working first though–the performance cost is nothing compared to rendering.

Please let me know if that helps or if you have more questions!

Hi Sam, thanks for the input, however the counter is for a single variable, on a level end game screen, displaying scores. Thus, there are no events to fire on that end game display.

My attempt works with larger numbers though, counts of single or double digits via array are too fast.

Just so I understand, you have one array variable, and one text with a function that displays/scrolls through players’ scores? The problem with binding text to a function is you can’t put any delays in functions, however you can put them in events.

If you want to have a specific delay between each score, I believe you need a custom event that gets the value from the array, sets the text to the value, delays, repeats, etc. Or make a separate variable (currentScoreText), and have a similar event setCurrentScoreText to the array value, delay, set to array value2, etc. Then trigger that event (setTimerByEvent 1 second looping) when your end game screen is constructed (Event Construct).

Basically what I have here should work…may have to change around how you get the TotalPlayers and PlayerNumber. Let me know if this helps!

Hi Sam, thank you for this example, which is a great learning example for multiplayer scores setup.

However, what i particular need is the counting of the numbers, not during gameplay (like your example outlines), but for an endgame screen, when the game may even be paused. Screen example Gameplay/Mages/Multiplayer/Quick/Dev/Snapshot/LOE - YouTube I’ve tried while, and foreach loops with putting each experience number (which should count from zero to max experience bonus), into an array, but still with 2 or 3 digit numbers, the process is too fast.