Game UIs and Logic Compares
Two of the most underused yet useful entities in Half-Life 2 are the Game_UI
and the Logic_Compare
. Although I can't think of one particular place in Half-Life 2 where either were used, they show promise to make some interesting single player and multiplayer entity setups that will provide a cool means of controlling other
entity setups. I'll go ahead and note that these are very boring examples, but they will be combined for a much more awesome result in the next tutorial assuming I ever write it.
What is a Game UI?
- A game_ui is an entity that forwards part of your controls to be triggers in the input/output system.
- It can be used to control various entity setups of your map with your primary/secondary fire mouse keys, and your movement keys.
What is a Logic_Compare?
- A logic_compare is an entity that triggers other entities based on satisfied conditions by comparing.
- It can be used to toggle entities on or off, open or closed, moving or not.
Setting these up are quite easy once you get the hang of them, you just have to understand the logic behind them.
Start by creating a testing room with an info_player_start
, a light_environment
, and a brush that will later be turned into a func_button
. Have a little room to make testing objects. Now, place a game_ui
somewhere within the map. The location is irrelevant, so long as you know where it is.
We will set the name
of it to UI
. Go to the flags and make sure only Freeze Player
and Hide Weapon
. Before we get too heavily involved, we'll setup the button before we move on. Hop back over to your button brush and tie it to a func_button
. In the flags make sure Dont Move
, and Use Activates
. Nothing else should be checked.
Now we need to set up the outputs to the button. Make sure they're like this: When you activate a game_ui
, your four movement keys and two mouse keys are forwarded to the game_ui
as outputs that you can trigger. These are the only 6 buttons that a game_ui
can take advantage of. Once you deactivate the game_ui
, your controls are returned to you.
Before we actually set up the game_ui
and the logic_compares
, we need to have something that each of the buttons can trigger. We are going to make two rotating cylinders and a laser to demonstrate how the controls work.
Make a cylinder and tie it to a func_rotating
then set the Max Rotation Speed
. Also check
the X Axis
in the flags. Make another cylinder next to it and Name
, set the Max Rotation Speed
, and then check
the Y Axis
and in the flags.
Now create an env_laser
next to your cylinders and name it something original such as Laser
. Type LaserTarget
into the Target of Laser
field and make sure Start On
in the flags. We can leave all other fields at default. Now make an info_target
above your env_laser
and name it LaserTarget
. You should now have something that looks a little like this:
Setting up the Game_UI and the Logic_Compares
Create three logic_compares
. Place one next to the first cylinder and name
. Place another next to the second cylinder and name
. Place the last one next to the laser and name
Go back to the Game_UI
from earlier and head to the Outputs
to make it look like this: If you fail to see what the Output triggers mean. X Axis
means that the UI
is forwarding your Left
and Right Movement keys
. For default controls, this is A
. The Y Axis
output means that it's forwarding your your Forward and Backwards
movement keys. For default controls, this is W
. As you look down on your keyboard, think of it like your X and Y axis graphs in math. The X
is the axis going from left and right while Y
is the axis going up and down. AttackAxis
means your primary fire
button (left click
). Although it is not used, AttackAxis2
means your secondary fire
button (right click
). Don't hesitate to mess with the other outputs in there as well.
In the target input
means that as long as you hold one of the UI forwarded buttons, the UI
sends a number to the logic_compare.
It will send it either -1
, or 1
. A value of 1
means that you are hitting either D
, while a value of -1
means that you are hitting either an A
. A value of 0
means that you are hitting nothing
at all. Don't worry about it if you don't understand, it should make more sense to you in the next part.
Now to set up the logic compares
, go to the various logic_compares
and make the outputs look like this:
Compare_1: Compare_2: Compare_3: A logic_compares default settings compare what outputs are sent to it based off of the compare value 0
(On equal to
). When you're holding down
a button and it sends it a 1
, it triggers the on greater than
outputs. When you're holding down
a button that sends it a -1
, it triggers the on less than
outputs. Now your forward
movement keys will make the first cylinder rock back and forth. Your left
movement keys will now make the second cylinder rock left and right. And now holding down your fire
button will make turn the laser on
These are the basic principles as to how Game_UIs
are used, but if you want to see a real
use, look at the next tutorial. We're going to go crazy with parenting. (At the moment, the 'next' tutorial isn't quite written. It will be, soon.)