Health Bars
So, I got health bars working! It required that I finish implementing my matrix multiplication code, which I was loathe to do. So far anytime I had to multiply matrices, I did it either inside shaders or via the many OpenGL matrix multiplication functions. My rotations and things were all done via quaternions, but I was forced to use matrix multiplication in software to get these looking right.
The width of the health bar is proportional to the width of the unit on the screen. The height, however, is constant...about 4 pixels. This allows you to gauge the health of a unit accurately even when it is far away. With a typical billboard type system, the health bar would get too small to see due to perspective correction. This, however, does a point projection to find out where on the screen the bar should go, and then does the rest in 2D window coordinates (to keep the constant height).
![health-bars]
EDIT: Here's another pic that shows how well the health bars work when you get zoomed out (and this, of course, is what the camera will typically be looking like):
![health-bars-again]
Comments
6 comments:
Wow, that is starting to all come together. Very cool.
IMO they should be wider (in height) than 4 px. Cuz when youll have much more elements on screen like the base, foliage (on Mars? :D ), particles and such, itll be hard to see those 4 px. I think you should try increasing it at least to 5-6.
It's amazing how much a tiny detail like health bars adds to the look of the game. It just really jumps out at you now and screams, "I'm an RTS!"
I guess I beat you to this idea, because I originally tried 6, then 5 pixels, before settling on 4. It looked junky because the health bars looked "fat". They just took up way too much vertical space. Remember, most of the time you'll be looking down from a far-off view, so the second screenshot above is the most accurate.
As of now, the health bars are shown on top of everything else, including billboards, particles, etc. The only thing that can obscure a health bar is another health bar, so there should be no problem seeing them even with more stuff on screen.
I definitely agree. It always seems to be the little things that get me more and more excited.
Yeah, you really beated me there :) I should say I didnt think about the fact that most of the time camera will be far away from the units, and judged only by the close screenshot.
我有頭痛!
Post a Comment
Fields marked with * are required.