hpbar float

i’m using a float variable for my healthbar variables for current health and max health. Now i added the following script which allows health Re/Degeneration.

curHealth+=1*Time.deltaTime;
curHealth = Mathf.Clamp(curHealth,0,maxHealth);

this script works like it has to: it adds 1 to the variable curHealth every second, but it displays the curHealth variable in my healthbar GUI now as a very long float. How can i make that variable to show as int, and how can i get the variable to be handled as int when accessed by other scripts?

Thanks in advance.

when displaying you should be able to create a new var int set it equal to curHealth and display the int

wow that was way easier than i thought :slight_smile: i was already trying to calculate the int with Mathf and stuff but that didn’t work. thanks for helping the beginners around here :wink:

Glad to help