Targetname is a base Keyvalue available in all games. A targetname (also known simply as Name) is the name of an entity. A targetname is not required for an entity to exist, but generally must be present for an entity to play a part in the I/O System.
- Entities may also be targeted by their classname (e.g.
- Targetnames do not need to be unique, they can be shared (and inputs will be sent to each one). Duplicated targetnames are displayed in bold font.
- Targetnames cannot contain
*characters (see below).
- Targetnames also cannot contain
,characters if you intend to use the entity as a parent, as this is used to set an attachment point.
- Instances may use prefix or postfix name fixups, and will auto-generate a prefix if no parameters are specified.
- Prefixes and Postfixes are separated by a single dash e.g. hall_a3-door_02.
- Placing an
@symbol at the beginning of a targetname (e.g. @exit_door) will bypass a naming fixup for that particular entity. If @exit_door and exit_door_relay were part of an instance prefixed as Door_01, the names of the entities would be @exit_door and Door_01-exit_door_relay.
In most multiplayer games, any entity with the following targetnames will have a Use input sent to them when that event occurs.
game_playerdie- Fires every time a
playerdies. The player who died is the
game_playerkill- Fires every time a
playerkills another player, the killer is the
game_playerjoin- Fires every time a
playerjoins the game, the joining player is the
game_playerspawn- Fires every time a
playerspawns, with the spawning player as the
game_playerleave- Fires every time a
playerleaves the game.
!activatorwill not work in this case, as the
playerentity no longer exists.
While searching for an entity, Source can use a few extended matching features that are useful in a variety of situations. They are used to target an entity with an unknown or partially known name, and they are most commonly used in I/O chains, but they can also be used in KeyValues which target entities, like the filter KV in
class or an entity's parent field. The extended features are:
- Source supports
*wildcards to a limited extent. This means searching for area1* will match any targetnames that start with area1, like area1_portal or area1_door, but not area2_door. These wildcards are also limited to trailing
*, which means more complex wildcards like *_door or area*_door will not function.
The I/O System also supports classname matching, which matches by an entity's classname rather than its targetname. This uses all of the same extended matching features listed above. Some other parts of Source support classname matching, but this usually isn't the case unless stated otherwise.
The following special targetnames can be used to dynamically select an entity.
- The entity that began the current I/O chain.
- If a player walks into a trigger that fires a
logic_relay, the player is the
!activatorof the relay's output(s).
- The entity from which the current input originates.
- If a player walks into a trigger that fires a logic_relay, the relay is the
!selfof its output(s).
- The entity from which the current output originates.
- If a player walks into a trigger that fires a logic_relay, the trigger is the
!callerof the relay's output(s).
- Targets the player.
- In multiplayer games, it targets the first player that joined the server.
- In Portal 2 Coop, this targets ATLAS (player 1).
- In Portal 2 Coop, this targets P-Body (player 2).
- The first player found in the entity's Potential Visibility Set. The PVS used is taken from the entity doing the searching, or the activator if no searching entity exists. If no activator exists either, the first player in the game is returned (i.e.
- The first entity under the player's crosshair; mostly only for debugging. Entities without collision can only be selected by aiming at their origin.
- In multiplayer games, it uses the first player that joined the server.
These keywords are only available in
FindNamedEntity, a method specific to NPCs which is only searched by specific systems (e.g. choreographed scenes) and not by things like the I/O System.
- The entity at which the
!calleris looking due to a Look At Actor or Face Actor choreography event.
!caller's nearest friendly NPC. This returns the player on NPCs which don't descend from
- The current enemy of the
!callercan be different for specific inputs, which depends on each input's implementation. In most cases this is in an undesired manner, like
- When an output's "Target Entity" is empty,
!selfis not set to the
- Targetnames used in an output's parameter override field are evaluated by the entity that receives the output, not the one that sends it.