Source Mapping, Materials, Modeling and Code tutorials.
Main Custom Files All Downloads Search all TutorialsSearch all Tutorials
Hosted by GBC Game Design program
Check out more Source tutorials at City 7: Toronto Conflict
 

Printer Friendly

Sliding Doors


There are other Door tutorials on this site

 Model door:  HL2 Prop Door

 Directional door:  One-way

 This door can be Flagged to be Oneway and Reverse direction:  Breakable door

Sliding doors can be varied:
1) Garage door that raises and lowers.
2) Door that zips open and closed.
3) Two doors that open and close together to form one door.
4) Glass door typical around pools.
5) Pocket doors found in home construction.
(I’ve built Pocket doors and Glass sliding doors in my house, they’re all great.)


You can create any of those with the same methods we’ll use here.

In this tutorial we’re going to build a simple door that opens quickly straight up and then closes to its original position.

There are lots of ways to build a door and give it the appearance of riding on a track.
Not all sliding doors have two tracks, some only need one that bears the weight of the door and keeps it from being unstable.

If you build the edges of your door into the walls you won’t even need to simulate tracks in most cases, up to you. My point in mentioning this now is it will be a lot easier to design and build your door and their surroundings with each in mind.

The door for this sample will have these characteristics:
a. Taller than the player.
b. Wider than the outstretched arms of the player.
c. Thin, giving it the appearance of being light but strong.
d. It will open straight up and it will close automatically in 1 second.
e. The door will wait for the player and it will not hurt the player.


Our door begins with a simple brush built with the nodraw texture or covered in the texture you want for your door. The advantage of building it with the nodraw texture is we can use the Face Edit tool to apply any of the various door textures in the SDK and use other textures for the sides and bottom. In most cases the top can remain textured with nodraw.

The brush for our door is 130 units wide, 144 tall and 8 units thick.


Press Ctrl+T and tie this brush to entity func_door then click Apply.

For those not sure how to do that here’s the step by step:
1) Select the brush you made for your door.
2) Press Ctrl+T
3) In the “Class” combo box select func_door.
4) Click on the lower right button “Apply”.
5) Your brush is now a func_door.

Set these properties for the door:
Name: Door01 (We give it a name so it can be referenced in our triggers.)
Speed: 220 (This is very fast; your doors will typically have a speed of 100)
Start Sound: doors/doormove2.wav
Stop Sound: doors/default_stop.wav
  Note: You can browser for many door sounds in the SDK.
Delay Before Reset: 1 (We want it to close quickly)
Lip: 0 (Won’t be sticking out at all, you may want to change this.)
  Note: Lip is the amount in unit inches the bottom/trailing edge of the door will be sticking out.
  Negative numbers cause the door to recede even further.
Blocking Damage: 0 (Change this to hurt or kill a player as the door closes.)
Force Closed: Yes
Move Direction: -90 0 0

Set this flag:
Touch Opens: Checked



The door will now work perfectly.
When the player touches the door, bumps into it, the door will open, it will wait 1 second and close. If the player doesn’t move out of the way it will rest on their head and when they do move it will close.

We can make this door a little better by creating trigger_multiple entities and placing them on each side of the door. Instead of the player needing to bump into the door they will cause the same toggle action for our door sooner and the player won’t need to stop or even slow down the door will open for them and close behind them automatically.

Notice in this shot from Valve Hammer 4 how I’ve created two additional brushes and tied them to entity trigger_multiple, then I’ve placed them on either side of our door.
I've applied the trigger texture to the brush.


Note: A trigger_once would work just as well to open our door, the reason we are using a trigger_multiple is to open and close this door over and over again.

These are the setting for both:
Class: trigger_multiple
Start Disabled: No
Delay Before Reset: 2

In the Flags check Clients. (Plus any others you want to trigger the door.)

This is the Output for both of our triggers:
OnStartTouch, Door01, Toggle (No delay, do not check “Fire only once”)

Step by step for those not sure how to create an Output:
1) Click on a trigger_multiple and press Atl+Enter to open the properties.
2) Click on the “Outputs” tab at the top of the properties dialog.
3) Click the “Add” button.
4) In “My output named” select “OnStartTouch”.
5) In “Targets entities named” select “Door01”.
6) In “Via this input” select “Toggle”.



Do the same for both triggers. You can also use the Copy and Paste buttons in the Outputs section and you can create the output for both at the same time by holding Ctrl and clicking on both to select them and then press Alt+Enter.

You don’t need these triggers but they are quick and easy to create and they will make a big difference in the performance of this door. Without them the player will need to bump into the door.

There are lots of ways to toggle a door like this, with gun shots, buttons or any sort of logic you may need in your maps.

This door toggles open and closed but it can be changed to open and stay open, to open and close via buttons, etc.

A nice effect with this method would be two identical doors that meet in the middle of a doorway and open to each side when the player comes to them and then they would close again. I’m sure you’ll come up with something.

UPDATE: Per request I've created another example for doors that slide to the left and right.
Both of these examples are in the download, example 2 is doors that slide sideways.
The "Move Direction" for each door is:
Right door: 0 270 0
Left door: 0 90 0


There’s a lot more you can do, I hope I’ve stimulated your imagination.Smile

  DownloadThe example used in this tutorial.





Valve, the Valve logo, Half-Life, the Half-Life logo, and the Lambda logo are trademarks and/or registered trademarks of Valve Corporation Site.