Game Development Community

1st/3rd Person PlayGui Difference

by Chris Byars · in Torque Game Engine · 04/26/2005 (5:58 pm) · 9 replies

What would be the best/easiest way to make it so if the player is in 1st person, he see's the regular "PlayGui", but if he tabs to 3rd, everything of the HUD disappears. (I could make a "PlayGui2" with no HUD elements on it)
How would I make it so that if you switch to 3rd, the "PlayGui2" becomes active, and if you switch back to 1st, the "PLayGui" first one comes back?

#1
04/26/2005 (6:00 pm)
Right now the tab key is bound to a function that changes between first and third person. I guess you could also make that function hide or unhide some gui elements.

EDIT: rather than having two GameTSControls, you could simply have all of the first person hud items set as the children of an invisible control, and when you switch between first and third person, toggle that control's visibility with "setVisible"
#2
04/26/2005 (6:16 pm)
In the C, place in the gui element make the gui stop rendering by putting a return if the player is in first person. Look at the player class to get the correct syntax, Im at work right now and don't have the source with me.
#3
04/26/2005 (6:21 pm)
If you want to do it the C++ way, like anthony suggested, you can look at the crosshair control; I think that's the way it does it.

I have a bias toward scripting solutions because the engine code scares me.
#4
04/26/2005 (6:28 pm)
Engine code scares me too.

client/scripts/default.bind.cs
function toggleFirstPerson(%val)
{
   if (%val)
   {
      $firstPerson = !$firstPerson;
   }
}

function toggleCamera(%val)
{
   if (%val)
      commandToServer('ToggleCamera');
}

moveMap.bind( keyboard, z, toggleFreeLook );
moveMap.bind(keyboard, tab, toggleFirstPerson);
moveMap.bind(keyboard, "alt c", toggleCamera);

So I would add in some kind of "setVisible" code with that to toggle the group?
#5
04/26/2005 (6:34 pm)
Yeah, right under the $firstPerson = !$firstPerson line. Something like this:

if (%val)
   {
      $firstPerson = !$firstPerson;
      FirstPersonGuiGroup.setVisible($firstPerson);
   }

If you do it like this the player will be able to unhide the controls with a few console commands, so I'd only do it this way if it's not a big deal if the player can do that. I assume that it's not a big deal since the player can see them by tapping the tab key.

EDIT: (forgot to finish my post)
#6
04/26/2005 (7:00 pm)
Thanks =)
I'll try that.
#7
04/26/2005 (7:15 pm)
Jeez I'm stupid. How do I group my GUI here correctly so I can use the code?

The GUI to toggle on/off starts at the GuiHealthBarHud.

www.clanlc.com/playGui.gui

I appreciate the help greatly.
#8
04/26/2005 (7:39 pm)
www.uccs.edu/~ahitchco/playGui.gui

Try that. The group is named "FirstPersonGuiGroup"
#9
04/27/2005 (1:44 pm)
Thanks a lot. Took a little modification to get it all functioning, but it works like a charm now. I appreciate it.