I’m trying to create a health and mana system where if the health is 40 and later on 2000 the health bar being displayed will never change it’s shape (unless health is being lost of course).
How can I do this?
I’m trying to create a health and mana system where if the health is 40 and later on 2000 the health bar being displayed will never change it’s shape (unless health is being lost of course).
How can I do this?
this is simple let us say the length of health bar is 250. you should set the length straight way, you should calculate the percent of total hp the player has rite now and multiply it with the length (250 in this case) and set it.
for example:
var maxHP:float=2000;
var currentHP:float=1750;
var percentOfHP:float;
void Update()
{
percentOfHP=currentHP/maxHP;
}
void OnGUI()
{
ExpBarLength=percentOfHP*250; /* 250 is the maximum length of the exp bar.
// set the length for exp bar.
}
PS : this method will work regardless of whether you exp bar is in 3d or GUI.
If you use Texture2D, well, just make the pictures the same length. No big deal.
If you use the GUI, you should be using something like health/total length to display the percentage of health.
Just change total length.