quake2 - target_crosslevel_trigger, target_crosslevel_target, target_changelevel

The target_crosslevel_* entities are used to trigger unit-wide events. Press a button (or series of buttons) in one level of a unit, and a door opens in another. They aren't all that hard to use, if you're comfortable with triggers and targets, but before we get started, there are a few things you should know about the target_crosslevel_trigger, and target_crosslevel_target entities:

1.) The target_crosslevel_ entities work by setting one or more of eight spawnflags, which are retained throughout a unit, which simply means you only get eight cross-level events per unit.

2.) Make sure you have a unit exit at the end of the last level of the unit, as not resetting the spawnflags results in fewer available spawnflags for the next unit. A unit exit is just a target_changelevel with an asterisk (*) in front of the actual map$startpoint keyvalue. Here are a few examples:

To go to e1u2 of the id levels (skipping the cinematic,) you would have a target_changelevel with the key 'map', which would have the keyvalue '*bunk1$start'

To go to e1u2 (including the cinematic,) you would have a target_changelevel with the key 'map', which would have the keyvalue 'eou1_.cin+*bunk1$start'

To go to e1u1 you would have 'map'='*base1' (because the start for base1 doesn't have a targetname)

3.) The crosslevel spawnflags are read when Q2 initializes the map, which means any crosslevel triggers will not have any effect until a level change.

With all of that in mind, let's start.

First off, let's create a room with an info_player_start. Decide where you want your exit to be. Make a brush with the 'trig' texture at the area you've chosen as the exit, and make it into a trigger. It doesn't matter if it's multiple or once, because we'll be using it to exit anyway. Make a target_changelevel, and give it a key of 'map' with a keyvalue of 'tcex2$from1'. In this case, the 'tcex2' is the next example map we'll be making; '$' means we'll be going to a specific info_player_start in tcex2; and 'from1' will be the targetname of that info_player_start.

Now create another info_player_start, and put it near, but not touching, the exit (preferably facing away from it, but that's up to you.) Give it a targetname of 'from2'. This is where you'll spawn if you come back to this map.

The next thing you need to do is set something up to trigger your target_crosslevel_trigger. This can be a button, item pickup, or anything that can trigger another event. Give it a target (we'll use tc1 for this example.) Now, create your target_crosslevel_trigger, and give it a matching targetname (again, tc1.) Set the flag for trigger1 in the entity window for your editor. Now, when you trigger it, the trigger1 spawnflag will be set for the next map.

Save the map as 'tcex1.map'

Now we need another level to go to. Create a room similar to the last, but with two exits this time. Set the keys for one target_changelevel to 'map'='tcex1$from2' and the other to 'map'='*base1'. Place an info_player_start near the exit that goes back to tcex1, and give it a targetname of 'from1'.

Now, create a target_crosslevel_target and set the trigger1 flag. Give it a 'target' of 'boom', and a 'delay' of '2'. Make a func_explosive, and give it a 'targetname' of 'boom'. Save the map as 'tcex2.map

Compile and run the map. If everything worked properly (cross your fingers, it helps) then you should be able to trigger in the first level, and then go into the second level, wait a second, and *boom*. Just to make sure, try not to trigger the target_crosslevel_trigger before you go into the second map.

For further experimentation, you can set up more than one target_crosslevel_trigger, each with a different trigger flag checked (1, 2, 3...), and then set up one target_crosslevel_target with those flags checked. Only after you've triggered all events will the target be fired.

In the example maps, the target_changelevel_trigger is a button. When you come to the second level, a window explodes so you can now exit the map, followed by base1. I hope you find this helpful, as it helped me to make it.


You can download the tcex1.map and tcex2.map. Be sure to compile both maps first, otherwise the second map cant be loaded.

Return to Tutorials Page...

All content 1998 by Shane 'Fishman' Sherman. This particular tutorial was created by GrrandMaMa and belongs to him. Quake and Quake2 are trademarks of id software. All rights reserved.