Game Development Community

Trying to use GuiShapeNameHUD

by Dean · in Torque Game Engine · 07/23/2007 (1:48 pm) · 7 replies

What I'm trying to do is create a function to show all the player's names above their heads when I press a key. I have a basic understanding of gui, and I know how to create, destroy, edit etc gui objects for the most part, but I don't know how to have the client find all the players on the screen and show gui for all of them. Once I figure this thing out I should be able to display damage and show chat text etc from there. I tried what they used on this thread:
www.garagegames.com/mg/forums/result.thread.php?qt=4549
but it didnt do anything. Maybe it's outdated? thanks for reading.

#1
07/23/2007 (9:07 pm)
GuiShapeNameHud is built in to Torque 1.5 (and 1.4 as well if I remember correctly). You just have to add it to your playGui, and make it cover the full area of the screen. It will automagically display names in the proper places over the heads of any player objects. You can find an example of this in starter.fps/client/ui/playGui.gui:

new GuiShapeNameHud() {
      profile = "GuiDefaultProfile";
      horizSizing = "width";
      vertSizing = "height";
      position = "0 0";
      extent = "653 485";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
      fillColor = "0.000000 0.000000 0.000000 0.250000";
      frameColor = "0.000000 1.000000 0.000000 1.000000";
      textColor = "0.000000 1.000000 0.000000 1.000000";
      showFill = "0";
      showFrame = "0";
      verticalOffset = "0.2";
      distanceFade = "0.1";
         damageFrameColor = "1.000000 0.600000 0.000000 1.000000";
         damageFillColor = "0.000000 1.000000 0.000000 1.000000";
         damageRect = "30 4";
   };
#2
07/24/2007 (7:36 am)
To turn it on and off, do you really have to go through all that mess Bryan Ross typed up of running through every object on the screen and setting it individually? Couldn't you just give your GuiShapeNameHud a name and say
if(%val)
  MyShapeNameHud.setVisible(!MyShapeNameHud.visible);
Or, to make the player hold the key so long as he wants to see names...
MyShapeNameHud.setVisible(%val);
Or something like that?
#3
07/24/2007 (10:44 am)
Thanks. i understand now, but it's interfering with object selection (clicking on a 3d object to select it). If I push playgui to back, object selection works and the nameHud doesnt. If I push namehud to back, namehud works but object selection doesnt. What do I need to do?
#4
07/24/2007 (11:38 am)
This objection selection?
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7335
It should already account for a GuiShapeNameHud control being there to capture the mouse events.
#5
07/25/2007 (5:06 am)
Dean, make sure you set you GuiShapeNameHud in our .gui file to use the profile of a Modeless dialog -- replace the profile field with the right one. :)
#6
07/25/2007 (7:40 am)
You can also put a bit of code in GuiShapeNameHUD to capture the mouse events, then pass them on to its parent GameTSControl.
#7
07/25/2007 (2:44 pm)
Ah that helps. I also did what mark suggested to return the players and the positions that the names are being drawn on the screen. thanks :)