For this you make a flipbook out of your sprites for the numbers (from Zero to 9, then their indexes in the flipbook align with the actual sprite numbers).
Then in your widget, you create one image for each digit (a speed in the 100 range requires 3 images, speed of 1000 4 images for 4 numbers/digits
), place them, where you want your speed to show up on your screen.
In the widget graph, You create a Flipbook variable and link it with your Numbers Flipbook.
Also create integer variables for all of your required digits, those will be used by your player/character to set the actual speed, and also to get the corresponding sprite from your flipbook to display it. I called them Digit001, Digit010 and Digit100.
And then the magic is just to get the sprite from your flipbook at a given index for each digit and make a brush out of this for your images in your Widget. I used a delay just to make it less sensitive, because the speed will usually be updated every frame, which can cause flicker in the display (in my case the engine calculated top speed between 499 and 500, constantly switching between those two values, creating a flickering display).
My complete graph for the widget, for a speed made out of 3 digits (max speed 999):
Then the messy part is in your character, where you have to get your current speed, break it up into it´s digits, transform those into integers, which you then cast to your Widget to your integer variables.
It´s a little bit messy, since there seems to not exist a function to break up integers into digits, so you have to build one.
I created an array of integers (SpeedDigitArray) containing 3 integers (max speed 999), where the speed will be written into. From this array i later get the integers and cast to the widget, to set the individual sprites for the digits in the Widget.
So you first need to transform your speed into a string. This string can then be converted into an array of all it´s characters (Get Character Array from String). To make life easier, reverse this array of strings - this makes casting to the Widget Digit variables less confusing.
Then loop through your SpeedDigitArray, and use its Array index to get the same Index from your StringArray (you should have a failsafe to make sure, that your String array is big enough, not that you access an index out of bound - i have a branch for that, comparing StringArray Lenght with the current index → if its bigger, then i set it to zero), write that into your SpeedDigitArray.
After the loop is complete, you can cast to the Widget, and finally get the integers from your SpeedDigitArray to set your variables in your Widget. Thats also the part where the reverse plays into, without the reverse the first index would be the 100 digit, or 1000, if you have higher speeds. With the reverse it starts with the 1 digit, second will be the 10 digit, third will be the 100 digit, etc.
The whole blueprint mess in one image, if the forum allows it:
Of course, the forum does not allow it ^.^ Link to Imgur, hopefully in full res.
How it can look like ingame: