Key Locked Door
by DrGlass (view all articles)

unrated
Make a door that can only be opened with a key card
by DrGlass (view all articles)

unrated

For this tutorial we will make a door that can only be opened once the player has picked up a key card.
First lets set up the situation. Make a room with a door leading to the high security area where the player wants to be.
Now tie your door to func_door and name it Door1 and remove the check for the Touch Opens flag.
Next we will make the key card that will unlock the door. I am going to use a prop_physics with the model models/Items/battery.mdl for the key- you can use what ever you want, though. Name your key card Key1.
Now create a brush around your key card and cover it with the trigger texture. Tie that brush to trigger_once. Name it Door1_trigger and set its parent to Key1.
Once you have done that we will make the button that will open the door. I placed a models/props_lab/keypad.mdl as my button prop and I have placed a brush with the nodraw texture on it over the keypad. This brush will act as the button. Tie the brush to a func_button. Name it Door1_button and check the Starts locked and Don't move flags.
For effect set a locked Sound and Unlocked sound, I chose the Access Denied/Granted sounds.
Here is the layout
Now lets set up the Inputs/Outputs:
Door1_trigger
Output = OnTrigger, Target = Key1, Input = Kill
Output = OnTrigger, Target = ,Door1_button, Input = Unlock
Door1_button
Output = OnPressed, Target = Door1, Input = Open
That is it! Once the player "picks up" the key he will be able to open the locked door.
Now that you made that work, let's jazz it up a bit. We are going to make a text message pop up and a sound play once the key has been picked up.
First make a game_text. Name it Key1_text and set the Message Text to say something like You found the blue key.
Then make a ambient_generic and name it Key1_sound. Pick a sound and change the settings until they please you.
Now go back to the Door1_trigger and add:
Output = OnTrigger, Target = Key1_sound, Input = PlaySound
Output = OnTrigger, Target = Key1_text, Input = Display
Now you have a working key card system in your map. This method will only work in single player maps.
Grab the example map here
First lets set up the situation. Make a room with a door leading to the high security area where the player wants to be.
Now tie your door to func_door and name it Door1 and remove the check for the Touch Opens flag.
Key Card
Next we will make the key card that will unlock the door. I am going to use a prop_physics with the model models/Items/battery.mdl for the key- you can use what ever you want, though. Name your key card Key1.
Now create a brush around your key card and cover it with the trigger texture. Tie that brush to trigger_once. Name it Door1_trigger and set its parent to Key1.
Door & Button
Once you have done that we will make the button that will open the door. I placed a models/props_lab/keypad.mdl as my button prop and I have placed a brush with the nodraw texture on it over the keypad. This brush will act as the button. Tie the brush to a func_button. Name it Door1_button and check the Starts locked and Don't move flags.
For effect set a locked Sound and Unlocked sound, I chose the Access Denied/Granted sounds.

Here is the layout
Now lets set up the Inputs/Outputs:
Door1_trigger
Output = OnTrigger, Target = Key1, Input = Kill
Output = OnTrigger, Target = ,Door1_button, Input = Unlock

Door1_button
Output = OnPressed, Target = Door1, Input = Open
That is it! Once the player "picks up" the key he will be able to open the locked door.
Extras
Now that you made that work, let's jazz it up a bit. We are going to make a text message pop up and a sound play once the key has been picked up.
First make a game_text. Name it Key1_text and set the Message Text to say something like You found the blue key.
Then make a ambient_generic and name it Key1_sound. Pick a sound and change the settings until they please you.
Now go back to the Door1_trigger and add:
Output = OnTrigger, Target = Key1_sound, Input = PlaySound
Output = OnTrigger, Target = Key1_text, Input = Display

Now you have a working key card system in your map. This method will only work in single player maps.
Grab the example map here