Download example file
Doors have been around since the days of Wolfenstein 3D. I mean, they're great things. There are two basic types you can create in Hammer, using two different entities. I will go over both in this tutorial.
A completed set of doors, each with the respective opening functions
Creating a sliding door
See also:
func_door
Firstly, the door on the left in the map (the metal one), is a
func_door
. To create the brush, simply find the texture that you want and size it. You might want to align the texture as well. There are a few frame textures that you can use as borders to your doors (as I have here). Create the frame first, then place the door inside it. Make the door slightly narrower than the frame, so that it looks more realistic. A good thing to do as well is to carve a bit out of the frame on the side that the door is going to slide, and then stretching the door brush a little less than that into the gap. This prevents that ugly mix of textures that can result from two brushes merging on the same line when the door opens.
You then need to attach the door brush to an entity - choose
func_door
. There are several attributes that you might want to set. Most importantly is the direction: use the little compass in the top-right to point the movement in the right direction. This will move the door in that direction on the Z axis (moving along the top view). You might want to assign a sound to the door's movement and stopping - you can try these out until you find one you like. Don't worry about the locked and unlocked sounds for this door.
Speed can be changed if you want, and
delay before close can be set to
stays open.
In flags,
Use only and
Toggle are useful ones to set.
Use only allows you to open the door only by going up to it and hitting your use key.
Toggle allows the door to be opened and closed, instead of just staying open (or automatically shutting after the
delay before close time). That's all you'll need for this door. It should now slide open into the wall when you press your use key near it.
Creating a swinging door
See also:
func_door_rotating
Now for the second door. This one uses a
func_door_rotating
and is slightly more complicated. Create the brush as before, perhaps making this one narrower, because the door rotates open (like the sort of door you have in your house), and can look very bulky if it's too thick. This time you will need to attach an origin brush to the axis of the door. The origin brush is just a normal brush using
origin
as its texture (a green picture of someone's face). The game looks for the centre of this brush, and treats it as the axis for rotation, so for this door, place it on the edge.
Select both the origin brush and the door brush and make them into a
func_door_rotating
entity. To do this click on the door so it is highlighted, hold down
Ctrl
and then click on the origin brush. Now use the
Tie to Entity button to assign the group to a
func_door_rotating
. The attributes for this entity are similar to the other door. The direction doesn't count though. There are also two other attributes -
Distance and
Pitch, yaw, roll angles.
Distance is the number of degrees that the door rotates through.
90° is fine. Ignore the second attribute - it's for creating more advanced rotations that aren't much use for a normal door.
Flags are also similar, added ones are the
reverse direction (which should be pretty obvious),
one way (door can only swing one direction), and X, Y axis options. The axis options can be confusing. You need to give an axis that the door rotates around the origin brush in. The default is
Z, which is top-view movement (what we are using). To work out what axis you want, take the name of the view window you want it to make a visible movement in, and the axis is the letter not in the name (i.e. If you are looking at the XZ view, then the axis is Y). It can be hard to visualize the available axes at first.
See also:
func_button
I've made this door slightly different to the first one, in that this one won't open unless you press the button to the left (not shown in the picture because I added it later). To create a button-triggered door, give the door a
name value, and make sure the door is
not use only, because that prevents triggering. Then assign a
locked sound if you want.
Unlocked sound isn't necessary if you assign a sound to the button. Create the button brush however you want, with whatever textures, and then tie it to the
func_button
entity.
Give the button a sound if you want and make the
target attribute the name of your door. The button's
delay before reset is quite important. If you make it
, then the button stays active until you press it again. If you choose
stays pressed then you aren't able to reset the button. Anything in between is the number of seconds until the button returns to 'off' position.
In flags, set
Toggle on so that the button's texture turns 'on' and 'off', and turn
Do not move on as well, so that the brush doesn't move (that's for plunger-type buttons etc.)
You should now find that the door opens and closes only when you press the button, and that when you attempt to open it by walking up to it, you get a locked sound. In the example map, the
delay before close is also set, and because there is no button on the other side of the wall, this is an effective way to trap players (not that you'd ever want to do that).
About the place to put it, the door will slide / rotate around it, usually I put it somewhere inside the door according to my needs. Just try it :).