so i try to make a health bar, i use GUITexture to create the bar, the width is 330 (for some reason it HAS to be like that)…
now i try to achieve how the bar could decrease on every attack that it receive…
and it’s done!
but the problem is i couldn’t convert the 330 into 100% bar length…
my code for attack is like this…
function Attack(){
var percenthp : float;
var tekstur : GUITexture;
var enemyhpdisplay;
var hplength ;
enemy_hp -= player_atk; //player_atk is 5 and declared in other place, so as enemyhp
//print(enemy_hp);
percenthp = (enemy_hp/enemy_maxhp)*100;
tekstur= GameObject.Find("enemyHp").GetComponent(GUITexture);
tekstur.guiTexture.pixelInset.width= percenthp;
}
so we know my healthbar width is 330, but everytime i click the attack the bar just drom from 330 width, into 95 width,… i couldn’t know how to convert it, so the width will decrease by percentage of the length… could anybody help me ?