Trigger changelevel: Difference between revisions
m (→Keyvalues) |
No edit summary |
||
(25 intermediate revisions by 13 users not shown) | |||
Line 1: | Line 1: | ||
{{ | {{LanguageBar}} | ||
{{ | {{subpage|[[Level Transitions]]}} | ||
{{note|This | {{TabsBar|main=gs|base=trigger_changelevel}} | ||
{{CD|CChangeLevel|file1=triggers.cpp}} | |||
{{this is a|brush entity|name=trigger_changelevel}} Upon being triggered, it will prompt the game to load another level. | |||
{{note|This entity does not work in multiplayer. If you need to change levels in a multiplayer game, you must call the <code>changelevel</code> command through either a {{ent|point_servercommand}} or code. This will not preserve entity states.}} | |||
{{note|In {{l4ds|4}} use {{ent|info_changelevel}}}} | |||
==Notes== | ==Notes== | ||
Place an [[info_landmark]] in both maps to mark the ''same'' location in both maps. | Place an [[info_landmark]] in both maps to mark the ''same'' location in both maps. | ||
The [[info_landmark]] must be in the [[player]]'s [[PVS]] when the level change is triggered. If it is not, the level change will fail. | |||
Both [[info_landmark]] entities must have the same name. This name must not have any spaces in it. They also must not be inside a solid brush. | |||
Both the landmark name and the map name must be less than 32 characters in length. | |||
{{note|Although the Landmark entity must be in the same place geometry-wise, it doesn't need to be in the exact location in the map's coordinates (This also includes height). A landmark could literally be placed anywhere in the new map grid thats being changed too, as long as the transition geometry surrounding it is exactly as the previous level's geometry. This can help with scenarios such as having large maps, i.e: The player traverses east of the top view, and must continue to do so in the next map, which would be impossible given starting the next map in the ending location. Simplifying your geometry near level transitions can make working on them much easier!}} | |||
Level transitions must be two-way. That is to say, there must be a trigger_changelevel in the next level that points to the current level, as well as the trigger_changelevel taking the player to the next level. If a one-way level transition is desired, simply make this second trigger_changelevel inaccessible to the player (and/or check the | Level transitions must be two-way. That is to say, there must be a trigger_changelevel in the next level that points to the current level, as well as the trigger_changelevel taking the player to the next level. If a one-way level transition is desired, simply make this second trigger_changelevel inaccessible to the player (and/or check the <code>Disable Touch</code> flag). | ||
{{warning|Although the [[info_landmark]] should be in a corresponding position in both levels, the two trigger_changelevel brushes must '''NOT''' be in the same place in each level. If they are, you will be thrown into an infinite loop, endlessly ping-ponging back and forth between the two levels.}} | |||
To fire events in the next level, use a trigger output to turn on an [[env_global]] in the current level. The entity has a few pre-defined states but you can manually type your own custom state. Create a [[logic_auto]] in the next level that checks for the state set by the env_global. Now use the '''OnChangeLevel''' output of the logic_auto to trigger events. | |||
To control which entities go through the level transition, create one or more [[trigger_transition]]s and give them the same name as the landmark. Any entities within the trigger_transition(s) will go to the next map. | |||
==Keyvalues== | ==Keyvalues== | ||
{{KV | {{KV Targetname}} | ||
{{KV|New Map Name|string|Name of the map to change to.}} | {{KV|New Map Name|intn=map|string|Name of the map to change to.}} | ||
{{KV|Landmark Name|target_destination|Name of the landmark to use. (See above for details!)}} | {{KV|Landmark Name|intn=landmark|target_destination|Name of the landmark to use. (See above for details!)}} | ||
{{KV StartDisabled}} | |||
==Flags== | ==Flags== | ||
{{Fl|2|Disable Touch}} | |||
{{Fl|4|To Previous Chapter}} | |||
==Inputs== | ==Inputs== | ||
{{ | {{I|ChangeLevel|Cause the level change. Use this when triggering the level change with a button, etc.}} | ||
{{Warning|Since | {{Warning|Since {{src07|4}} this input will do nothing when used on a multiplayer server.}} | ||
{{I EnableDisable|Enable/disable this entity.}} | |||
==Outputs== | ==Outputs== | ||
{{ | {{O|OnChangeLevel|activator=activator of {{mono|ChangeLevel}} input|Fired when the level changes.}} | ||
{{sensor brush}} | {{sensor brush}} |
Latest revision as of 02:19, 11 June 2025
![]() |
---|
CChangeLevel |
![]() |
trigger_changelevel
is a brush entity available in all Source games. Upon being triggered, it will prompt the game to load another level.

changelevel
command through either a point_servercommand or code. This will not preserve entity states.


Notes
Place an info_landmark in both maps to mark the same location in both maps. The info_landmark must be in the player's PVS when the level change is triggered. If it is not, the level change will fail. Both info_landmark entities must have the same name. This name must not have any spaces in it. They also must not be inside a solid brush. Both the landmark name and the map name must be less than 32 characters in length.

Level transitions must be two-way. That is to say, there must be a trigger_changelevel in the next level that points to the current level, as well as the trigger_changelevel taking the player to the next level. If a one-way level transition is desired, simply make this second trigger_changelevel inaccessible to the player (and/or check the Disable Touch
flag).

To fire events in the next level, use a trigger output to turn on an env_global in the current level. The entity has a few pre-defined states but you can manually type your own custom state. Create a logic_auto in the next level that checks for the state set by the env_global. Now use the OnChangeLevel output of the logic_auto to trigger events.
To control which entities go through the level transition, create one or more trigger_transitions and give them the same name as the landmark. Any entities within the trigger_transition(s) will go to the next map.
Keyvalues
- Name (targetname) <string>[ Edit ]
- 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
- New Map Name (map) <string>
- Name of the map to change to.
- Landmark Name (landmark) <targetname>
- Name of the landmark to use. (See above for details!)
- Start Disabled (StartDisabled) <boolean>
- Stay dormant until activated (with the
Enable
input).
Flags
- Disable Touch : [2]
- To Previous Chapter : [4]
Inputs
- ChangeLevel
- Cause the level change. Use this when triggering the level change with a button, etc.


EnableDisable:
- Enable / Disable
- Enable/disable this entity.
Outputs
- OnChangeLevel
- !activator = activator of ChangeLevel input
!caller = this entity
Fired when the level changes.