This article's documentation is for anything that uses the Source engine. Click here for more information.

Game ui: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (Robot: fixing template case.)
m (Substituted IO templates)
 
(24 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{wrongtitle|title=game_ui}}
:''Not to be confused with [[GameUI]].''
{{base_point}}[[Category:GUI Entities]]
__NOTOC__
 
{{CD|CGameUI|file1=game_ui.cpp}}
== Entity description ==
{{this is a|point entity|name=game_ui|engine=Source}} It redirects important player key presses to a series of outputs, and can be used to make the player control vehicles built in a map. It can be activated with I/O, or by the player looking at it.
An entity used to override player input when the player is looking at it.
{{note|You must have one instance of game_ui per player in multiplayer as each game_ui only activates for one player at a time.}}
{{note|Bots can use this entity and fire its outputs.}}
{{bug|Due to an oversight, game_ui will disable client prediction causing laggy behavior on multiplayer.}}


== Keyvalues ==
== Keyvalues ==
*{{KV Targetname}}
{{KV Targetname}}
*'''[[FOV|FieldOfView]]'''
{{KV|FieldOfView|intn=FieldOfView|float|The amount of tolerance in the view checking when determining whether the player's input is still under control.}}
: <float> The amount of tolerance in the view checking when determining whether the player's input is still under control. 1.0 = straight ahead, 0.0 = +/- 90 degrees, -1.0 = all directions. If the player isn't within the tolerance, the player regains control.
:*'''1.0''' = '''straight ahead'''
:*'''0.0''' = '''+/- 90 degrees'''
:*'''-1.0''' = '''all directions'''


== Flags ==
== Flags ==
*32 : Freeze Player
{{fl|32|Freeze Player - The player cannot move (they can still crouch though)}}
*64 : Hide Weapon
{{fl|64|Hide Weapon - Disables all the player's weapons
*128 : +Use Deactivates
::{{note|This will cause the player to go into their reference (T) pose.}}}}
*256 : Jump Deactivates
{{fl|128|+Use Deactivates}}
{{fl|256|Jump Deactivates}}


== Inputs ==
== Inputs ==
*{{I Targetname}}
{{I|Activate|The [[!activator]] will gain control upon this input being fired.}}
*'''Deactivate'''
{{I|Deactivate|The entity will only test FieldOfView if it is active.{{bug|The game will crash if the <code>Deactivate</code> input is fired on a game_ui that was activated by a player who has since disconnected. Fixed in {{tf2|2}}}}{{workaround|[[AddOutput]]ing OnUsers to a player and using a [[logic_branch]] together can be sufficient to workaround this. If the game supports it, [[VScript]] can also be used to check if the player entity still exists before firing the input.}}}}
:Return Player Control.{{warning|Deactivating an inactive game_ui crashes the game}}
*'''Activate'''
:Take Player Control.


== Outputs ==
== Outputs ==
*{{O Targetname}}
The player is always the [[!activator]].
*'''PlayerOn'''
{{O|PlayerOn}}
:Fired whenever this entity starts controlling the player's input. {{PlAct}}
{{O|PlayerOff|Fired when the entity starts or stops controlling the player's input.|since=}}
*'''PlayerOff'''
{{O|PressedMoveLeft}}
:Fired whenever this entity stops controlling the player's input. {{PlAct}}
{{O|UnpressedMoveLeft|Fired on +moveleft/-moveleft|since=EP2}}
*'''PressedMoveLeft'''
{{O|PressedMoveRight}}
:Fired whenever the player presses the moveleft key. {{PlAct}}
{{O|UnpressedMoveRight|Fired on +moveright/-moveright|since=EP2}}
*'''{{EP2 add|UnpressedMoveLeft}}'''
::{{bug|The left/right movement outputs do not fire when using a controller. {{elaborate|game this was tested in}} }}
:Fired whenever the player unpresses the moveleft key. {{PlAct}}
{{O|PressedForward}}
*'''PressedMoveRight'''
{{O|UnpressedForward|Fired on +forward/-forward|since=EP2}}
:Fired whenever the player presses the moveright key. {{PlAct}}
{{O|PressedBack}}
*'''{{EP2 add|UnpressedMoveRight}}'''
{{O|UnpressedBack|Fired on +back/-back|since=EP2}}
:Fired whenever the player unpresses the moveright key. {{PlAct}}
{{O|PressedAttack}}
*'''PressedForward'''
{{O|UnpressedAttack|Fired on +attack/-attack|since=EP2}}
:Fired whenever the player presses the forward key. {{PlAct}}
{{O|PressedAttack2}}
*'''{{EP2 add|UnpressedForward}}'''
{{O|UnpressedAttack2|Fired on +attack2/-attack2|since=EP2}}
:Fired whenever the player unpresses the forward key. {{PlAct}}
{{O|XAxis|param=float}}
*'''PressedBack'''
{{O|YAxis|param=float|Fired whenever the X/Y axis of the player's input changes.}}
:Fired whenever the player presses the backward key. {{PlAct}}
:* -1.0 = +moveleft / +back at 100% speed
*'''{{EP2 add|UnpressedBack}}'''
:* 0 = no movement in this axis
:Fired whenever the player unpresses the backward key. {{PlAct}}
:* +1.0 = +moveright / +forward at 100% speed
*'''PressedAttack'''
{{O|AttackAxis|param=float}}
:Fired whenever the player presses the attack key. {{PlAct}}
{{O|Attack2Axis|param=float|An output that fires whenever the state of the player's "attack" key changes.}}
*'''{{EP2 add|UnpressedAttack}}'''
:* 1.0 = trigger is 100% depressed
:Fired whenever the player unpresses the attack key. {{PlAct}}
:* 0 = trigger is at rest
*'''PressedAttack2'''
::{{note|These do not actually output analog values, even when using an analog stick; it will only be <code>1</code>, <code>0</code>, or <code>-1</code> depending on which keys are considered pressed. (Because of the above bug, this also means that <code>XAxis</code> never fires when using a controller.) {{elaborate|game this was tested in}} }}
:Fired whenever the player presses the secondary attack key. {{PlAct}}
 
*'''{{EP2 add|UnpressedAttack2}}'''
[[Category:Level Design]]
:Fired whenever the player unpresses the secondary attack key. {{PlAct}}
*'''XAxis''' <float>
:An output that fires whenever the X axis of the player's input changes. i.e. -1 when the player has "moveleft" key down, 1 when the player has moveright key down, and 0 if neither.
:{{PlAct}}
*'''YAxis''' <float>
:An output that fires whenever the Y axis of the player's input changes. i.e. -1 when the player has "backward" key down, 1 when the player has "forward" key down, and 0 if neither.
:{{PlAct}}
*'''AttackAxis''' <float>
:An output that fires whenever the state of the player's "attack" key changes. i.e. 1 when the player has the "attack" key down, 0 otherwise.
:{{PlAct}}
*'''Attack2Axis''' <float>  
:An output that fires whenever the state of the player's "secondary attack" key changes. i.e. 1 when the player has the "secondary attack" key down, 0 otherwise.
:{{PlAct}}

Latest revision as of 21:44, 19 April 2025

Not to be confused with GameUI.
C++ Class hierarchy
CGameUI
CBaseEntity
C++ game_ui.cpp

game_ui is a point entity available in all Source Source games. It redirects important player key presses to a series of outputs, and can be used to make the player control vehicles built in a map. It can be activated with I/O, or by the player looking at it.

Note.pngNote:You must have one instance of game_ui per player in multiplayer as each game_ui only activates for one player at a time.
Note.pngNote:Bots can use this entity and fire its outputs.
Icon-Bug.pngBug:Due to an oversight, game_ui will disable client prediction causing laggy behavior on multiplayer.  [todo tested in ?]

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

FieldOfView (FieldOfView) <float>
The amount of tolerance in the view checking when determining whether the player's input is still under control.
  • 1.0 = straight ahead
  • 0.0 = +/- 90 degrees
  • -1.0 = all directions

Flags

Freeze Player - The player cannot move (they can still crouch though) : [32]
Hide Weapon - Disables all the player's weapons
Note.pngNote:This will cause the player to go into their reference (T) pose.
 : [64]
+Use Deactivates : [128]
Jump Deactivates : [256]

Inputs

Activate
The !activator will gain control upon this input being fired.
Deactivate
The entity will only test FieldOfView if it is active.
Icon-Bug.pngBug:The game will crash if the Deactivate input is fired on a game_ui that was activated by a player who has since disconnected. Fixed in Team Fortress 2 Team Fortress 2  [todo tested in ?]
PlacementTip.pngWorkaround:AddOutputing OnUsers to a player and using a logic_branch together can be sufficient to workaround this. If the game supports it, VScript can also be used to check if the player entity still exists before firing the input.

Outputs

The player is always the !activator.

PlayerOn
PlayerOff
Fired when the entity starts or stops controlling the player's input.
PressedMoveLeft
UnpressedMoveLeft  (in all games since Half-Life 2: Episode Two)
Fired on +moveleft/-moveleft
PressedMoveRight
UnpressedMoveRight  (in all games since Half-Life 2: Episode Two)
Fired on +moveright/-moveright
Icon-Bug.pngBug:The left/right movement outputs do not fire when using a controller.
Elaborate?: game this was tested in
  [todo tested in ?]
PressedForward
UnpressedForward  (in all games since Half-Life 2: Episode Two)
Fired on +forward/-forward
PressedBack
UnpressedBack  (in all games since Half-Life 2: Episode Two)
Fired on +back/-back
PressedAttack
UnpressedAttack  (in all games since Half-Life 2: Episode Two)
Fired on +attack/-attack
PressedAttack2
UnpressedAttack2  (in all games since Half-Life 2: Episode Two)
Fired on +attack2/-attack2
XAxis <floatRedirectOutput/float>
YAxis <floatRedirectOutput/float>
Fired whenever the X/Y axis of the player's input changes.
  • -1.0 = +moveleft / +back at 100% speed
  • 0 = no movement in this axis
  • +1.0 = +moveright / +forward at 100% speed
AttackAxis <floatRedirectOutput/float>
Attack2Axis <floatRedirectOutput/float>
An output that fires whenever the state of the player's "attack" key changes.
  • 1.0 = trigger is 100% depressed
  • 0 = trigger is at rest
Note.pngNote:These do not actually output analog values, even when using an analog stick; it will only be 1, 0, or -1 depending on which keys are considered pressed. (Because of the above bug, this also means that XAxis never fires when using a controller.)
Elaborate?: game this was tested in