Game Development Community

GUI Health Bar Problems...

by Kirby Webber · in Torque Game Engine · 07/19/2005 (7:00 pm) · 9 replies

I'm having a very stange issue with the guiHealthBar HUD.

For clarity - I am using the racing mod and this is the stock file that is provided in HEAD (1.4).

I've changed the following code fragment:

ShapeBase* control = conn->getControlObject();
   if (!control || !(control->getType() & PlayerObjectType))
      return;

to this:
ShapeBase* control = conn->getControlObject();
   if (!control || !(control->getType() & VehicleObjectType))
      return;

Now, each time I add in a guiHealthBarHud to the GUI everything works as it should - health displays and decrements and energy displays as well when selected.

What's got me stumped is that each time I restart the engine, it completely drops the health/ energy meter from the gui - although they are still present in the playGUI.gui script. =\

Any advice?

(I am aware of the guiVehicleHealthBar resource but it crashes this version of HEAD in ways I can't begin to understand. =\)

#1
07/20/2005 (6:51 am)
Bump for the morning crew...
#2
07/20/2005 (7:12 am)
Each time you restart the GAME ENGINE? O_o That's odd. Have you tried to delete the DSO's or something? I can't see why it wouldn't work when you restart, nothing is saved.
#3
07/20/2005 (7:19 am)
That's what's killing me!?

I look at the script and the meters are still defined, but don't render (yes, "visible" is set to true. I checked. ;)

I have deleted the *.dso's to force a recompile and it still ignores them.

If I add a new one to the gui, it works for as long as that particular instance runs - as soon as I close it out and restart it, it's gone. =\

Understand that I am NOT using the guiVehicleHealthBar resource at this point - I'm modifying the guiHealthBar already present in the engine and intended to be used with the player class... if that helps.
#4
07/20/2005 (7:46 am)
NoTE that code is the onRender

You are saying if the controlling object is not a vehicleObjectType to return . . .ie exit out of the function, and in turn it will not call any of the rendering calls such as
dglDrawRectFill(rect, mDamageFillColor);

ps if you want one for both player and vehcile complie in the vehiclehealthgui and add to the playgui as well, that is why I made it =)
#5
07/20/2005 (8:05 am)
You know, that occurred to me last night, but what's strange is that, without the change, the healthbar doesn't render at all for a vehicle object.

[edit] In reviewing your statement, and the code again - yes... that's exactly what I want - only render for a vehicle.[/edit]
#6
07/20/2005 (8:06 am)
Incidentally:

Quote:
ps if you want one for both player and vehcile complie in the vehiclehealthgui and add to the playgui as well, that is why I made it =)

I'm really only working with vehicles as the player object, so I have no real need to use both at the present time.

From my original post:

Quote:
(I am aware of the guiVehicleHealthBar resource but it crashes this version of HEAD in ways I can't begin to understand. =\)
#7
07/20/2005 (8:22 am)
You know, I really hate not being at home so I can try this, but should it be:

ShapeBase* [b]vehicle[/b] = conn->getControlObject();

?
#8
07/20/2005 (6:08 pm)
No, that's just a variable name. You can name it purplemonkeydishwasher if you want.
#9
07/21/2005 (6:59 am)
Actually, I figured it out last night after fiddling with the code a bit.

Turns out I broke my own cardinal rule: "Always start with the simplest things first".

I named my gui elements (which I always do and think is good convention), but I named them with a space. =\

Take the space out and voila!

I felt as relieved as I did stupid when I realized what the problem was. ~heh