My game will have very large numbers, and i need to shorten them for the player to read.
My main issue is that I do not know how to shorten these as strings (i am using strings to bypass the float limit).
For example, how would i make a number such as 1,234,567 show up as 1.234 million? Or a number such as 111,222,333,444 show up as 111.222 billion?
This is the setup for the UI, “shown income” will show the actual number (in its short form) and the “income short” will display million, billion, trillion etc as needed.
So my question is, how would i shorten the number down and make the text update depending on the incomes value?
Take your number, check if is greater than 1 billion: if it is, divide it by 1 billion using the Division (whole and reminder node). Take the whole part, convert it to string and append the word " billion" (note the space in front). This is your shortened output.
Otherwise check if your number is greater than 1 million: if it is, divide it by 1 million using the Division (whole and reminder node). Take the whole part, convert it to string and append the word " million" (note the space in front). This is your shortened output.
Otherwise check if your number is greater than 1000: if it is, divide it by 1000 using the Division (whole and reminder node). Take the whole part, convert it to string and append the word " thousand" (note the space in front). This is your shortened output.
I think you got the point. You can extend it to do trillions as well. Here is the node to use:
You can use FindSubstring to search for the position of the decimal point, then add 3 to it to keep 3 digits after the decimal point. Finally use the Left function on the string, passing the above value, to isolate the integer part plus the decimal point plus 3 digits after it.
Hey, sorry for digging out this old thread, but I’m having the same issue as OP and vr_marcos solution doesnt seem to work for me.
I have a counter in game which can potentially reach billions.
So I’m trying to shorten my counter if it reaches a certain number. For example, instead of displaying 1000 I want it to say 1k. If I use the solution posted here, my counter just gets divided by 1k which effectively resets it
My blueprint is attached. Annyone knows whats wrong with it?