- Home /
My life bar isn't working
As the title says, when I create the GUI for my life bar, there isn't anything showing up inside of it. I took the code from http://unity3d.com/support/documentation/Components/gui-Layout.html and instead of using public float playerEnergy = 1.0f; I used my own public float health = 50f; that I have been using in my whole script.
I do get the nice bar at the top, but no filler for the actual health. Even when I use the playerEnergy = 1.0f; I do not get anything in the bar. What gives here?
Answer by phren · Jun 13, 2012 at 12:32 PM
Without seeing your project I'd guess it's one of two possibilities:
1) You haven't set the fgImage texture
2) playerEnergy has to be between 0.0 and 1.0 (which I guess you have already tested, but it should be in this range in any case (playerEnergy/maxPlayerEnergy))
1) That is news to me really. I read the webpage as it would automatically do that for me since there was a picture following the code. Reason I say that is because the other code examples gave me what the pictures showed as well.
2) What is the reason behind the 0.0 and 1.0? I am using the code provided and creating my own Evac-City game via the tutorial from http://www.rebelplanetcreations.com/downloads/Other/Tutorials/HowTo$$anonymous$$akeAGameInUnity3D.pdf The reference to health is on page 27.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How to make OnGUI Texture able to be clicked 1 Answer
Drawing Multiple Textures to the GUI during runtime 1 Answer
GUI texture outside of OnGUI 2 Answers