Turn float to int

I multiplied a float with Time.deltaTime like: SomeFloat -= 0.001 * Time.deltaTime
And i’m showing the “SomeFloat” float graphicaly with GUI.Label, and it works like it’s supposed to, reduces by -0.001 every second… I’m actually making a precent, like how much % is left of “SomeFloat” in the GUI.Label, It’s good, but it’s like 99.999 %, 99.998 %, 9.997 … 0.001 %
But i want it to display it as an classic 2 or 1 spaces long number (Like 99.998 % shows like 99%)
So i never worked with ints, using C#, but my guess is that int doesen’t show dots, just full numbers… SOOO, i guess i need to show float as an int ? Or is there some other solution ? I don’t know anymore, this is probabbly confusing, i couldn’t explain better, i’m sorry.

2 Answers

2

ToString is what you want. Try this answer out.

Found a way before i read this answer, but thank you for your time anyway

–

I came up to an answer by searching, i just made a new int, and said it’s = to (int)Somefloat, which turns somefloat to an int

Just be aware that casting to an int will require some more work if you want to add commas, or a couple of decimal points.

–

Thanks for this, I had the same question and this totally helped

–