Creating a Portal 2 Coop Map

Category:Portal 2 Level DesignCategory:Portal 2 tutorials
==Basic Steps==
Here are the basic steps needed to create a coop map:
* Create a . Set its VMF file to one of the coop spawn rooms, such as <instances/coop/coop_spawn_room.vmf. These VMF files already contain an , so don't create another one.
* Create another func_instance, this one set to one of the level end rooms, such as instances/coop/coop_endlevel_room.vmf. 
* Build your map in between these rooms. (You can move them, of course.) The embedded VMF files have an obvious exit which should lead into your map. You may need to enclose the rooms in order to prevent leaks.
* Make sure you save the map with the prefix mp_coop_.
That's it! See Testing Portal 2 Co-Op Maps Alone for how to test the map without a partner. (To test it with a partner, both must have the .bsp file. Get into the hub normally, then the host should changelevel to the map.)
=Co-op Level Without Spawn Instances=
=== Step 1: Necessary entities ===
To create a co-op level, you need to use:
* a 
* TWO s
*a 
* TWO s
* TWO s
* a 
* TWO s (place them where you want the players to start)
=== Step 2: Names ===
* Name your first logic_relay "relay_return_hub"
* Name your second logic_relay "@relay_has_new_taunt"
* Name your logic_coop_manager "coopmanage_return_hub"
* Name your first logic_script "script_return_hub"
* Name your second logic_script "@script_mp_coop_lobby"
* Name your first prop_indicator_panel "panel_level_return_orange"
* Name your first prop_indicator_panel "panel_level_return_blue"
* Name your info_coop_spawns "spawns_1"
=== Step 3: Properties ===
1. Go to script_return_hub's properties and do the following:
::
Property Name 	Value
Name 	script_return_hub
Entity Scripts	debug_scripts/mp_coop_transition_list.nut
2. Now go to the @script_mp_coop_lobby's properties and do this:
::
Property Name 	Value
Name 	@script_mp_coop_lobby
Entity Scripts	debug_scripts/mp_coop_lobby.nut
3. Continue to the panel_level_return_orange properties:
::
Property Name 	Value
Name 	panel_level_return_orange
Time Duration 	3
Is a timer? 	Yes
Indicator lights	tex_level_return_orange
4. Continue to the spawns_1s' properties:
::
Property Name	Value
Name 	spawns_1
Team 	<red or blue, depending on wich player>
5. Give the prop_button the following properties:
::
Property Name 	Value
Delay Before Reset	3
=== Step 4: Outputs/Inputs === 
Now we need to connect all these entities together.
; Outputs
::
	My Output 	Target Entity 	Target Input 	Parameter 	Delay	Only Once
	OnMapSpawn	@script_mp_coop_lobby	RunScriptCode 	CheckForNewTaunts() 	2.00 	No
	OnMapSpawn	script_return_hub 	RunScriptCode 	MapPostLoaded() 	2.00 	Yes
	OnMapSpawn	script_return_hub 	RunScriptCode 	SetMapBranchAndLevel()	0.25 	Yes
	OnMapSpawn	spawns_1 	SetAsActiveSpawn	<none> 	0.00 	No
; Outputs
::
	My Output 	Target Entity 	Target Input	Parameter	Delay	Only Once
	OnChangeToAllTrue	relay_return_hub 	Trigger 	<none> 	0.00 	No
	OnChangeToAllTrue	panel_level_return_orange	Check 	<none> 	0.00 	No
	OnChangeToAllTrue	panel_level_return_blue 	Check 	<none> 	0.00 	No
*relay_return_hub Outputs
::
	My Output	Target Entity 	Target Input 	Parameter 	Delay	Only Once
	OnTrigger	script_return_hub	RunScriptCode	ReturnToHubFromLevel()	1.00 	Yes
*@relay_has_new_taunt Outputs
::
	My Output	Target Entity 	Target Input	Parameter	Delay	Only Once
	OnTrigger	brush_new_taunts	Enable 	<none> 	0.00 	Yes
* Outputs
::
	My Output 	Target Entity 	Target Input 	Parameter	Delay	Only Once
	OnButtonReset	panel_level_return_orange	Stop 	<none> 	0.00 	No
	OnButtonReset	coopmanage_return_hub 	SetStateBFalse	<none> 	0.00 	No
	OnPressed 	panel_level_return_orange	Start 	<none> 	0.00 	No
	OnPressed 	coopmanage_return_hub 	SetStateBTrue 	<none> 	0.00 	No
That's it! You now can create co-op maps with working co-op scripting!
== Trivia ==
* When a map is exactly named mp_coop_community_hub.bsp it can be also run with the map command.