Snarkpit Articles

Key Locked Door

Make a door that can only be opened with a key card
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.

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.

Article image

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

Article image


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

Article image


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

Discussion

Posted by Tracer Bullet on Wed Jan 19th 2005 at 5:55pm

Nice simple workaround for a gameplay feature HL doesn't directly support.
Posted by Guessmyname on Tue Jan 18th 2005 at 4:53pm

Posted by DrGlass on Tue Jan 18th 2005 at 3:55pm
[Author]

Done!
Posted by Anthony on Tue Jan 18th 2005 at 10:49am

Good tutorial, and yeah, as gemini said, that red writing is a real strain on the eyes. Consider perhaps, changing it to white? :)
Posted by DrGlass on Tue Jan 18th 2005 at 9:34am
[Author]

Had to keep the picture small, admin's order
Posted by gemini on Tue Jan 18th 2005 at 9:32am

Very nice tutorial

my only crit would be the blurry red line/text in your illustration are an eyesore...

otherwise it's clean, simple, and organized.
Posted by DrGlass on Tue Jan 18th 2005 at 8:35am
[Author]

Cant wait!
Posted by satchmo on Tue Jan 18th 2005 at 2:36am

Thank you so much. This will be incorporated as the final touches in my single-player map. Not only did you go over the basics (very clearly), but you also have the additional jazzy things to make the setup more elaborate.

You'll see the setup in my new map as soon as next week.