Health Bars
SurfWAlien21
Member Posts: 1
I am going to attempt to explain what I have accomplished, and what my problem is as best i can. I wanted to create separate health bars for each enemy I place in a scene. So I created a general 'Monster' actor and gave that actor an individual attribute with its own 'enemy health' (not a game attribute). I have my main 'Hero' shooting bullets, thus when the bullet overlaps/collides with the 'Monster' his 'enemy health' is reduced by 1, and when it reaches 0 he is destroyed (typical). I also created another actor 'Monster Health Bar' which I then drag on the screen and unlock to start adding more attributes. The 'Monster Health Bar' is a small square that replicates to the right the amount of enemy health that is remaining, so it is linked to the 'Monster' attribute 'Enemy Health'. I also locked its position to be above the 'Monster' so no matter where the monster is, the health bar follows. I also messed with the alpha channel, set it to 0 so it does not appear until the bullet overlaps/collides with the monster, only then it appears for 1 second (set with a timer), then it reverts back to alpha 0, so it disappears. I also have the rule set that when the Monster's Enemy Health = 0 then the health bar is to be destroyed. This all worked beautifully, and I was so excited. I would walk my Hero up to the monster shoot it a couple times and the health bar would appear, and diminish, then disappear. Then i would continue to finish him off and both the monster and the health bar were destroyed. So I saved, and started doing more work, creating some other actors for health packs and such, then while testing out my game again, I noticed that now the health bar that was above my monster still appears after the monster is destroyed. It works perfectly up until the monster is destroyed, still diminishes the correct way, and still only appears for 1 second after the monster is hit with a bullet, but as soon as the monster disappears, the bar stays on and never goes away. So if I delete the health bar, create a new one from scratch, it works perfectly again, until I start making some other stuff. Then the health bar gets stuck again. Please help if you can, this is really bothering me and slowing down my progress. I Hope this all makes sense. I have seen a lot of posts about Health Bars, and came up with a fantastic solution, except for this one hiccup that I don't seem to understand. Thank you!
Comments