- Home /
how to remove the health bar without destroying the script
so my problem is when my enemy runs out of hp its dead so its gone but its health bar is still there i want to remove it if the hp is 0 without destroying the script because if i destroy the script there will be many errors so here's what happens
you see there's still some of the health bar how can i atleast make it disappear when enemy hp is 0
Answer by getyour411 · Feb 14, 2014 at 03:19 AM
Your image link didn't come through to me, but one approach would be to modify your OnGUI (assuming you have one) to something like
if(itAINTDEAD)
displayGUITexture;
You have asked a slew of reasonably simple questions in a few days, please take advantage of the tutorials.
http://unity3d.com/learn/tutorials/modules/beginner/scripting
aw thank you for the link i really need that but anyway, i uploaded the picture again i hope you see it, thanks for the help i hope i can ask you again if i have questions but im going to study first this time hehe
The enemies should all have unique attributes. It looks like you are using a public static health variable for the enemy? If so that is not a good application of a public static variable and will cause all kinds of problems.
Enemy health should be public if necessary so you can access the variable, but never public static or that means that one enemy health variable will control all your enemy behaviors ins$$anonymous$$d of individuals.