Hello everyone,
I have fun into an issue with this script… I use a simular script on mobs and turrets and it has no issues taking damage and destroying but adding the script to the player and adding textures to show what the health is at I just cant seem to get to work. Its just stuck at the initial image of 100% health… No errors come up either, any help is greatly appreciated, thanks alot in advance.
Thanks,
G~
var hitPoints=100.0;
var explosion:Transform;
var health100:Texture2D;
var health90:Texture2D;
var health80:Texture2D;
var health70:Texture2D;
var health60:Texture2D;
var health50:Texture2D;
var health40:Texture2D;
var health30:Texture2D;
var health20:Texture2D;
var health10:Texture2D;
var health00:Texture2D;
var healthtexture=gameObject.Find("healthoverlayc100");
function TakeDamage(amount : float){
hitPoints-=amount;
var exp = Instantiate(explosion, gameObject.transform.position, Quaternion.identity);
if(hitPoints<100){
healthtexture.guiTexture.texture=health90;
}
if(hitPoints<90){
healthtexture.guiTexture.texture=health80;
}
if(hitPoints<80){
healthtexture.guiTexture.texture=health70;
}
if(hitPoints<70){
healthtexture.guiTexture.texture=health60;
}
if(hitPoints<60){
healthtexture.guiTexture.texture=health50;
}
if(hitPoints<50){
healthtexture.guiTexture.texture=health40;
}
if(hitPoints<40){
healthtexture.guiTexture.texture=health30;
}
if(hitPoints<30){
healthtexture.guiTexture.texture=health20;
}
if(hitPoints<20){
healthtexture.guiTexture.texture=health10;
}
if(hitPoints<10){
healthtexture.guiTexture.texture=health00;
}
if(hitPoints <= 0.0){
Destroy(gameObject);
}
}