im new and have been making a very basic game by watching tutorials for what i need, the problem is i have a enemy with a health bar that that decreases with damage but wont die, i have make 3 different multi page scripts that didn’t work and i cant find an answer anywhere, i just need a script that will make a gameobject be destroy when another specific object is destroyed(the health bar).
Well, I dont know of you are doing 2d or 3d but you simply reference your health bar like this…
if( healthbar == 0 )
{
Destroy(gameObject);
}
You womt destroy your health bar per say, rather destory the gameObject. So if the health bar is at 0, then the player should be destroyed and then gsmeover applied. So where it says
Destroy(gameObject)
Replace gameObject with your character. And the healthbar to what ever name you are using. Upload your script on here, using the proper code tag, press the code button above and paste it. And I’ll help you out.