HUD - Add 0's to unused number places.
I have a HUD for my shooter that has the number of pieces of ammo go down every time you shoot. Problem is, my max ammo is 150, and I want it to go down to 000 when I'm out, but instead it just shows 0. How would I add 0 to a number to a number place I'm not using in my HUD?
What I'm talking about (the zeros I would want added are bolded.):
150 - 100
099 - 010
009 - 001
In my HUD: http://i.imgur.com/IZf5wwR.png
In my Event Graph in my character: http://i.imgur.com/WUR4m0h.png
asked Dec 10 '15 at 02:31 AM in Blueprint Scripting
in the HUD, instead of casting the Int into Text, you should first cast it into a string. as a string, you can use Len to get the number of characters in the string, as an integer.
you can make an integer variable called MinimumDisplayDigits, and set its default value to 3. if the Len of the string is less than MinimumDisplayDigits, you can subtract the Len of the string from MinimumDisplayDigits, and use the result as the LastValue in a ForLoop, which can append placeholder 0s to the string. when the forloop completes, or when the Len of the string is not less than MinimumDisplayDigits, you can cast the string to text, and display it in your HUD.
Another way to do this is to append your number as a string to a set number of zeros and then use the "right" bp function to only take the right part of the string that you want. Example: I want a character string representation of a number that has a leading zero if only one character. In other words if the value is 0-9 then display as 00-09, but if 10-99 then display 10-99.
answered Aug 16 '18 at 05:36 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here