- Home /
Health Bar to Render On Top
Hello,
I am using a 'plane' as a health bar which basically changes size and colour depending on a health variable. Is it possible to render this plane object on top of everything else?
Example:
The main camera is looking directly downward, and there is an object in my scene with a health bar. There is also a tree next to that object which is obstructed the view to the health bar plane, because of this, I would like to know how to render on top ... or is there another methord?
Thanks
If you make it a guiTexture it will always be rendered on top. Look into them here: http://unity3d.com/support/documentation/ScriptReference/GUITexture.html
I cant use the GameObject (plane) as a Texture though
You might be able to find a shader that will draw it on top.
Answer by Meltdown · May 17, 2011 at 07:11 AM
I would suggest having two cameras in your scene. In Unity cameras with lower depth are rendered before cameras with higher depth, in other words a camera with a depth of 2 will be drawn on top a camera with a depth of 1.
1.) Your main camera for showing your game, set depth to 1 2.) A second camera with depth set to 2, place your plane in your second cameras view.
Because the second camera's depth is more than the first camera, it will render your plane in front of what the first camera renders.
Answer by Kourosh · May 17, 2011 at 05:09 AM
Add this line inside the shader pass:
ZTest Always
It'll always be rendered no matter whats behind or whats on top.
Your answer
Follow this Question
Related Questions
Camera displays view on object 1 Answer
script dosnt creat object where i want it to 1 Answer
Is there a way to do this effect/shader? 1 Answer
how to scale an object in order to fix the screen dimensions 3 Answers
game object hide 1 Answer