Game Development Community

How do you hide bot name and health?

by Jason Davis · in Torque Game Engine · 08/01/2006 (10:58 am) · 9 replies

Well, I have tried and tried to figure this out to no avail. I have successfully created bot characters using the AIGuard resource as a guide.

I don't like the name of the bot and his health displayed on the screen. (Ya know, the words in green.) Let me know if anyone can help me with this. Thanks!

#1
08/01/2006 (11:01 am)
Make the GuiShapeNameHud invisible.
#2
08/01/2006 (3:39 pm)
I just checked out that resource and this should do it:

search the aigaurd.cs for
%player.setShapeName(%name);

then when you find it just comment it out and then the name wont be shown. I couldnt find one for health since I cant remember what its called. I know this works when spawning players or any other object so hopefully it should work here.


Jon
#3
08/02/2006 (7:09 am)
Okay guys, thanks for the tips! I have successfully implemented this and thought I would share it with all of you for your own possible use.

In playGui.gui, you will see this code:
new GuiCrossHairHud() {
      Profile = "GuiDefaultProfile";
      HorizSizing = "center";
      VertSizing = "center";
      position = "496 368";
      Extent = "32 32";
      MinExtent = "8 8";
      Visible = "0";
      bitmap = "./crossHair";
      wrap = "0";
      damageFillColor = "0 1 0 1";
      damageFrameColor = "1 0.6 0 1";
      damageRect = "50 4";
      damageOffset = "0 10";
         helpTag = "0";
   };
Instead of this code, I deleted it and typed this:
new GuiCrossHairHud(CrossHairOnly) {
      Profile = "GuiDefaultProfile";
      HorizSizing = "center";
      VertSizing = "center";
      position = "496 368";
      Extent = "32 32";
      MinExtent = "8 8";
      Visible = "1";
      bitmap = "./crossHair";
      wrap = "0";
         helpTag = "0";
   };
   new GuiCrossHairHud(CrossHairShowBotHealth) {
      Profile = "GuiDefaultProfile";
      HorizSizing = "center";
      VertSizing = "center";
      position = "496 368";
      Extent = "32 32";
      MinExtent = "8 8";
      Visible = "0";
      bitmap = "./crossHair";
      wrap = "0";
      damageFillColor = "0 1 0 1";
      damageFrameColor = "1 0.6 0 1";
      damageRect = "50 4";
      damageOffset = "0 10";
         helpTag = "0";
   };
This CrossHairOnly gui is to display a simple cross hair only. The CrossHairShowBotHealth shows the bot's health bar when it is targeted with your crosshair. Notice that by default, the latter is invisible and the former is visible. And as far as the ShapeName goes, I gave it a name such as this:
new GuiShapeNameHud(BotShapeName) {
...and made it invisible by default such as this:
Visible = "0";
So now, when I load up the mission, it does not show the bot's name or health bar. BUT I decided it might be handy to be able to turn all of this back on if I needed it, which of course, is why I gave the gui controls those names. So in default.bind.cs, I typed in the following:
$metricsActive = false;
function toggleMetricsInfo(%val)
{
   if (%val)
   {
	$metricsActive = !$metricsActive;
	GLEnableMetrics($metricsActive);
	CrossHairOnly.setVisible(!$metricsActive);
	CrossHairShowBotHealth.setVisible($metricsActive);
	BotShapeName.setVisible($metricsActive);
	if ($metricsActive)
	    metrics(video);
	else
	    metrics(0);
   }
}
moveMap.bind(keyboard, "ctrl m", toggleMetricsInfo);
So now, by pressing CTRL + M, I can not only bring up all of the helpful metrics information I have come to rely on (Thanks to Aaron Ellis for showing me this) but I can also turn the names and health bars of the bots on and off each time I hit the keystrokes.

Let me know if this is helpful to anyone... Thanks for all you guys do!
#4
08/02/2006 (8:08 am)
An easier approach would have been to bind a function that toggles the GuiShapeNameHud to visible or not visible.

No GUI modifications are required this way.

E.g.

function toggleShapeNameHud(%val)
{
   if (%val)
      ShapeNameHud.toggle();
}

function ShapeNameHud::toggle(%this)
{
   if (!ShapeNameHud.visible)
      ShapeNameHud.visible = 1;
   else
      ShapeNameHud.visible = 0;
}

moveMap.bind( keyboard, "ctrl m", toggleShapeNameHud );
#5
08/02/2006 (1:21 pm)
Tim,

The only thing about it is that your code only affects the name, not the health bar. Also, you MUST modify the gui from the original if you don't want it to show by default.
#6
08/02/2006 (1:28 pm)
Big deal, then hide the crosshair control if you dont want to see health bars.
#7
08/02/2006 (6:35 pm)
Jason,

Sorry I forgot about the health bar. I still don't think you're going about it the best way with your method, but it's only a simple function so I suppose it doesn't matter all too much. I was just trying to show you how to simplify your code.

Another example:

function toggleShapeNameHud(%val)
{
   if (%val)
      ShapeNameHud.toggle();
}

function ShapeNameHud::toggle(%this)
{
   if (!ShapeNameHud.visible)
   {
      ShapeNameHud.visible = 1;
      crosshair.damageFillColor = "0 1 0 1";
      crosshair.damageFrameColor = "1 0.6 0 1";
   }
   else
   {
      ShapeNameHud.visible = 0;
      crosshair.damageFillColor = "0 1 0 0";
      crosshair.damageFrameColor = "1 0.6 0 0";
   }
}

moveMap.bind( keyboard, "ctrl m", toggleShapeNameHud );

All I'm doing there is altering the alpha channel of the crosshair damage fill, frame in order to show and hide it. Once again, no need to create two GUI's.

Just throwing some alternatives out there.

- Tim
#8
08/04/2006 (11:39 am)
That's a good tip, Tim. Thanks alot... I will try out your method because it would simplify things somewhat. :-)
#9
05/14/2007 (7:39 pm)
Does anyone know how to show the health bars and crosshair in the third person view? Or if the crosshair isn't possible, just the health bars so they're always on? Or on just for a certain type of bot?