func_button
Jump to navigation
Jump to search
Tip:If you have a button over a prop, which fires outputs by damaging the button brush, you might as well use a prop_dynamic with its "OnTakeDamage" output. This will use the props collision mesh as the button, instead of a brush.
This is very useful for small items, since small button brushes may compile with missing faces, due to a vbsp bug.
Note:For Keyvalues and Inputs affecting brush rendering, see Brush entity/Rendering related keyvalues and inputs
Tip:Use func_rot_button instead for non-solid buttons in other games, or use a %CompileNonSolid material.
Bug:In Half-Life 2 series nonsolid buttons may cause you to interact with things besides or behind the buttons.
![]() |
---|
CBaseButton |
![]() |
func_button
is a brush entity available in all Source games.
It is designed to be used for a player-usable button. When +used by the player, it moves to a pressed position.
For an example of a func_button
used to make a keypad, see the button_keypad prefab.

This is very useful for small items, since small button brushes may compile with missing faces, due to a vbsp bug.
Keyvalues

- Name (targetname) <string>
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentname
ortarget
).
Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
- Glow Entity (glow) <targetname> (only in
)
- The name of an entity that will get a +use glow for this button.
Bug:The Engine cannot properly find the Glow entity if it's off-grid. It will pick several entities close to where the supposed off-grid glow entity is. [todo tested in ?]
- Use Look-At Limit (min_use_angle) <string> (in all games since
)
- Limit the usable look-at angle. -1 is looking directly away, 0 is looking perpendicular, 1 is looking directly at. To allow a deviation of at most 45°, insert cos(45°) ≈ 0.7071 or for 5° use cos(5°) ≈ 0.9962 (see dot product).
- Move Direction (Pitch Yaw Roll) (movedir) <angle>
- Specifies the direction of motion to move when the button is used.
- Delay Before Reset (-1 stay) (wait) <integer>
- Amount of time, in seconds, after the button has been pressed before it returns to the starting position. Once it has returned, it can be used again. If the value is set to -1, the button never returns.
- Speed (speed) <integer>
- The speed that the button moves, in units per second.
- Health (Obsolete) (health) <integer>
- Legacy method of specifying whether or not the button can be shot to activate it. Use the Damage Activates spawnflag instead.
- Lip (lip) <integer>
- The amount, in inches, of the button to leave sticking out of the wall it recedes into when pressed. Negative values make the button recede even further into the wall.
- Sounds (sounds) <integer choices>
- Make this button emit a sound when pressed.
Note:The list below was made for Half-Life 2. All games support this keyvalue, but some don't have a number of these sound files. To edit these sounds, look for
Buttons.snd
(followed by a number from the Value column in this table) inhl2/scripts/game_sounds_world.txt
or your game's appropriate Soundscript file.
ExpandChoices
- Locked Sound (locked_sound) <integer choices>
- Sound played when the player tries to use the button, and fails because it's locked.
ExpandChoices
- Unlocked Sound (unlocked_sound) <integer choices>
- Sound played when the button is unlocked.
Confirm:doesn't seem to work?
ExpandChoices
- Locked Sentence (locked_sentence) <integer choices>
- A sentence played when the player tries to use the button, and fails because it's locked.
ExpandChoices
- Unlocked Sentence (unlocked_sentence) <integer choices>
- A sentence played when the button is unlocked.
ExpandChoices
- Master (Obsolete) (master) <targetname>
- Legacy support: The name of a master entity. If the master hasn't been activated, this button cannot be pressed.
Flags
Don't move : [1]
Toggle : [32]
- Makes the button fire the outputs "OnIn" and "OnOut" if being pressed repeatedly.
Does not fire "OnOut" when "Damage Activates" is also set. As a workaround you can have this button "press" another button somewhere out of reach, which only has the "toggle" and "don't move" flag.
Touch Activates : [256]
Damage Activates : [512]
- If set, makes the button fire "OnPressed" when damaged. Honors the lock like any other input option.
"OnDamaged" would fire any time the button is pressed, even if locked.
Use Activates : [1024]
Starts locked : [2048]
Sparks : [4096]
Non-solid : [16384] (in all games since (also in
))


Inputs
- Lock
- Lock the button, preventing it from functioning.
Bug:Do not lock while pressed; it will not return when unlocked. [todo tested in ?]
- Unlock
- Unlock the button, allowing it to function.
- Press
- Activate the button as if it was pressed.
- PressIn
- Activate the button as if it was pressed, sending it to the bottom position.
- PressOut
- Unpress the button, sending it to the top position. Fire OnPressed output.
Outputs
- OnDamaged
- Fired when the button is damaged, regardless of whether it is locked, or if the "Damage Activates" is set.
Example:This could be used to destroy a locked button to open doors, while pressing "+use" would play a "Deny" sound.
- OnPressed
- Fired when the button is activated through any means set by the flags.
- OnUseLocked
- Fired when the button is used while locked.
- OnIn
- Fired when the button reaches the in/pressed position.
- OnOut
- Fired when the button reaches the out/released position. "Delay Before Reset" will fire this output, after the delay is over. If the "Toggle" flag is set, pressing the button again will fire this output.