CBaseTrigger
Code classes:
CBaseTrigger
(triggers)CBaseToggle
CBaseEntity
(all ents)
CBaseTrigger
is a base class for all trigger entities. Usually triggers are tied to a brush that causes them to react in some way when another entity enters that volume.
Classnames:
(Not in FGD) - Useless entity. Usetriggertrigger_multiple
for regular triggers.
Triggers may also be point entities that simply specify a volume with their Minimum Bounding Box Size (mins)
and Maximum Bounding Box Size (maxs)
. Defining the volume this way is easier to do for entities that are created post-compile, but usually the method isn't sought by level designers because brushes are easier to manipulate.
Tip: Many projectile entities are coded to not activate triggers. If a trigger doesn't work, try detecting them with func_breakable
and filter_activator_class
!
Tip: Remember to set the spawnflags
keyvalue when trying to use base trigger functions such as OnStartTouch on a trigger which doesn't show them in Hammer. They are there, and it's unlikely that they've been inhibited.
ConVars/Commands[edit | edit source]
ConVar/Command | Parameters or default value | Parameter Type | Effect |
---|---|---|---|
showtriggers | 0 | 0 disables, 1 enables | Makes brush triggers visible on spawn. Mins/maxs entities can use ent_bbox . |
showtriggers_toggle |
| Makes brush triggers invisible or visible instantly. |
Flags[edit | edit source]
- 2: NPCs may trigger.
- 4: Pushables may trigger.
- 8: Physics Objects may trigger.
- 16: Only player ally NPCs - NPCs must be player allies to trigger. Sets NPCs automatically.
- 32: Only clients in vehicles - Players must be in a vehicle to trigger. Sets Clients automatically. (Not in .)
- Bug: Seems like this only detects once? Observed on trigger_teleport.
- 64: Everything (not including physics debris) may trigger.
- 1024: Physics debris may trigger. Debris objects are usually small and not solid to players.
- 2048: Only NPCs in vehicles - NPCs must be in a vehicle to trigger.
- 4096:
Correctly account for object mass (trigger_push used to assume 100Kg) and multiple component physobjs (car, blob...)fortrigger_push
only. (available in all games since )
Editors: Alien Swarm is able to detect players with the exact same flags used in HL2 because asw_marines actually are both player allies and npcs.
Keyvalues[edit | edit source]
Master(master)
<target_destination>
- Name of a
multisource
that will allow or disallow the trigger to fire depending on if themultisource
has been Used. This is obsolete through multiple means in Source. - Filter Name
(filtername)
<filterclass>
- A filter entity to test potential activators against.
- Start Disabled
(StartDisabled)
<boolean>
- Stay inactive until Enabled.
Inputs[edit | edit source]
- TouchTest
- For testing if something is currently touching the trigger. Fires either the OnTouching or OnNotTouching output.
- StartTouch (Not in FGD)
- Fires the OnStartTouch output.
- EndTouch (Not in FGD)
- Fires the OnEndTouch output.
- DisableAndEndTouch (only available in Half-Life 2: Deathmatch)
- Disables this trigger and acts as if all currently touching entities have stopped touching it immediately.
- Enable
- Makes the entity active.
- Disable
- Makes the entity inactive.
- Toggle
- If on, turn off. If off, turn on.
Outputs[edit | edit source]
- OnStartTouch
- Fired when a valid entity starts touching this trigger.
- OnStartTouchAll
- Fired when a valid entity starts touching this trigger, and no other entities are already touching it. If there are any other entities touching the trigger when a new one begins to touch, only OnStartTouch will fire.
- OnEndTouch
- Fired when a valid entity stops touching this trigger.
- Warning: If the
!activator
of this output is a player who disconnected, any entity trying to see what the activator was can cause a crash. - OnEndTouchAll
- Fired when all valid entities stop touching this trigger.
- OnTouching
- Fired if something is currently touching this trigger when sent TouchTest.
- OnNotTouching
- Fired if nothing is currently touching this trigger when sent TouchTest.