Snarkpit Articles


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.


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


Post ReplyView Topic
Discussion
0 starsPosted by joure on Sat Aug 9th 2008 at 11:10am

Oh man, I wanted to do exactly the same kind of tut.
I did my key thing almost exactly the same way, instead of trigger brush
I parented my model to a physbox, anyway nice to see this in a tut.
Oh and instead of a battery pack I used the key model from lostcoast.
Anyway, I gues I won't have to make a tut about this then., nice job mate.
[author]
Posted by DrGlass on Fri Jun 29th 2007 at 3:21am

I'm sure there are other possible ways to achieve this, many that would work in multilayer. A multi player tutorial would be a good sister tut.
0 starsPosted by FIDDLER on Mon Jun 25th 2007 at 10:14am

Mudbee... simply put a func_button on the inside of the room. When the player activates the button have the trigger close the door then lock it. Use the I/O functions on the func_button to do this.

If it's for multiplayer... Make sure to disable the button on the outside when your button on the inside is triggered so other players can't enter the room. However!!! give the other players some type of activator somewhere that un-locks the door otherwise some kid will get in that room and lock everyone else out smiley.

Question about the tutorial...

Why does it only work for single player levels? Perhaps a few tweaks could get it to work for multiplayer? Like... perhaps the key card could re-spawn after a given amount of time so others could use it to unlock the door again? Then after they go through the door a trigger could close the door and reset the whole process after a time period has passed.
0 starsPosted by TomClark21 on Thu Feb 15th 2007 at 1:40pm

Thank you, your Tut Really helped me set off my first map, hopefully i can incorporate a few more useful key/door things thanks to you.
0 starsPosted by Windows 98 on Tue May 10th 2005 at 11:12am

Great Tut, Helped me a lot

And for anyone trying to downlaod the sample map there, you have to right clcik and type properties, then copy the URL into the adress bar, then change the www.snarkpit.com thing to .net

or just type in or click the link <a href="http://www.snarkpit.net/editing.php?page=files&amp;download=196" target="_blank">http://www.snarkpit.net/editing.php?page=files&amp;download=196</a>
0 starsPosted by JWNET on Sat Jan 22nd 2005 at 7:08pm

Makes Sense... Thx!
[author]
Posted by DrGlass on Thu Jan 20th 2005 at 11:23pm

I'm sure its possible, but it would be very hard. This is a work around that give the player the illusion that he has the key when infact he is only setting off a trigger that unlocks the door.
0 starsPosted by JWNET on Thu Jan 20th 2005 at 8:04pm

Great Tut, but if you could figure out how to use it in HL2DM that would be great! Or would valve have 2 update Source SDK first? Either way I would like 2 know...
0 starsPosted by mudbeed on Thu Jan 20th 2005 at 6:03pm

Hey I wanna know how I can make a door that would be locked on the inside after a user pressed a button. I am making a control room in CS where the user can walk into a room with monitors and I want them to be able to lock the door after themselves. How can i modify this tutorial to allow me to do something like this.
0 starsPosted by Mr. Wiggles on Wed Jan 19th 2005 at 8:27pm

Great tut - thank you very much!
Post ReplyView Topic