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?
Thanks.
What I’m talking about (the zeros I would want added are bolded.):
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.
I will love you forever. The day I met you, champagne fell from the sky. Butterflies filled the air. It was beautiful, because you are. I will eternally hold you deep within my soul. You are the apotheosis of human excellence, progressiveness, and knowledge.
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.
This will expose a function to your blueprints that adds leading zeroes to a three digit number. If you want more leading zeroes, change the “3” in the “%03d” in the function and recompile the C++.
It’s very simple. Just use the ‘To Text (integer)’ node. Hit the down arrow to expand the node, then type 2, 3, or 4 (or however many numbers you want) in the 'Minimum Integral Digits box. Whallah! You now have preceding Zero’s on your single digits.
So if you type 3 in the box, this will turn 0 into 000 and 32 into 032 etc.