Guide to Portal Hammer Button + Door Part 2
Here you go.
Portal Button and Door Tutorial
Ok, so lets create a portal map. I'm going to assume you already know the basics of Hammer Editor, IE applying textures, creating solids, creating entities. If you don't I would suggest finding another tutorial as this is beyond the scope of this tutorial.
Luckily for you this will explain barebone design and creation of a portal map. Portal maps use more entites than ants at a picnic. Portal maps use alot of linked entities, if you were to map out a single portal room, it would probably look like this (trust me, I did)
http://www.cfs.dl.ac.uk/cgi-bin/bugzilla/docs/images/dbschema.jpg
Step 1: Creating the Room
The first step is to create a basic room. Don't bother making anything fancy, just create a square and hollow it out if your really lazy. You can find portal textures in my 1.5 guide here (viewtopic.php?t=38), just remember they will show up as purple textures in the map editor, but when you go to compile and run the map they will show up like normal.

ze=18]Step 2: Adding the Spawn Point[/size]
Portal uses the info_player_start entity as the spawn point, so create an info_player_start entity where you want the player start. If you do not have an info_player_start the player will spawn at the origin ( 0, 0, 0 ) and you'll need to noclip to your map.

### Step 3: Adding the Portal Gun
The next step is adding the portal gun to your map so the player can grab it. Create a "weapon_portalgun" entity and make sure "Can Fire Portal 1" and "Can Fire Portal 2" properties are set to "Yes". Otherwise our Portal gun will be useless. You can change this to what ever you want, it's preference really just depends on what kind of map your making weather you want them to be able to fire both portal or just one.

Save and run your map. You'll see that you can pick up the portal gun and fire portals around your small room. Congratulations, you've made your first portal map! Remember if your using the workaround be sure to copy the maps from your hl2mp folder from Half-life 2 Deathmatch to your Portals maps folder. I'm not sure if this is neccessary but it's the way I do it. Your map should be played in portal anyway.
### Step 4: Adding a Button.
Base
The first step to adding the button, is to create the base of the button. So, create a prop_static entity and change the model property to "models/props/button_base_reference.mdl". Click apply and you'll see the start of our very first button.
Top
Next, we want to add the button that we'll be standing on. Create a prop_dynamic and change the model to "models/props/button_top_reference.mdl". Also, set the "parent" property of our button to "button_door". The reason for this, is because were going to create a door under the button and have the top of the button move with it, so when we want the button to go down when we stand on it, we simply "open" the door so it will move both entites down. Center it on the button base and raise lower it to desired height. Make sure you keep some space under the button so it has room to move down and fit our door entity.
Button Door
Once you've done this its time to create the door that our button will move with. Create a small cylinder solid primitive and place it between the base and the button. Set it's texture to "tools/toolsnodraw" because we don't want to see this when the game runs, anything you set to the nodraw texture will not be visible when the game is ran. We need to convert it to a brush entity, so to do this go to Tools -> Tie to Entity and change the entity type to func_door. et the name property of our door to "button_door" and make sure the move direction is "90 0 0"
Button Trigger
The final step to adding our button is to create the trigger that will cause the button to react. Create a solid brush square and place it over our button. It should be very thin so it does not trigger when the player walks near it. When the player or box moves into this trigger space it will cause the button to move. Change the texture of the solid to "tools/toolstrigger" and convert it into a brush entity like we did with the button door by going to Tools -> Tie to Entity and change the type of the entity to trigger_multiple. Set the name to "button_trigger".

Now we have to create the outputs that occur when the player steps on the button. Go to the output tab of the trigger_multiple and click the Add button. Add the following outputs.
[My output named] -> [Targets entities named] -> [Via this input]
OnStartTouch -> button_door -> Open
OnEndTouchAll -> button_door -> Close

Once you have finished, save and test your map. You'll see that if you step on the button your button will activate just like the buttons in Portal. Congratulations. You've created your first button.
### Step 5: Adding the Door
Ok, now all we have to do is add the door.
The first step to adding the door is to add the door frame. To do this create a prop_static and change the model to "models/props/door_01_frame_wide_reference.mdl". This will serve as the base for our door. You can put this anywhere in the room but don't bother trying to carve it into a wall just yet. To do that your going to want to create some solids and use vertex manipulation as well as carving.
Next, create two prop_dynamics. Set the name of the first prop_dynamic to door_left and change its model to "models/props/door_01_lftdoor_reference.mdl". You also want to change the parent entity to door_left_door Set the name of the second prop_dynamic to door_right and change its model to "models/props/door_01_rtdoor_reference.mdl". Change the parent entity to door_right_door.You'll see that you now have the two door panels. Align them inside of the door frame to your satisfaction.
Almost done! Now like before when we created the button, we'll need to create two func_door's that will move the door panels. Create two solid square brushes and line them up with the door panels. use Tool -> Tie to Entity to change them to func_door brush entities. They should end touching each other in the middle of the door. Set the left func_door brush's name to door_left_door and the Move Direction to "0 90 0" Do the same for the second func_brush on the right and set its name to door_right_door and change its movement direction to "0 270 0". Set both of their textures to "nodraw".

All we have to do now is to add the outputs for the button to open the door and were done. Open the trigger_multiple you created when adding the button and go to the output tab. Add the following outputs.
[My output named] -> [Targets entities named] -> [Via this input]
OnStartTouch -> door_left_door -> Open
OnStartTouch -> door_right_door -> Open
OnEndTouchAll -> door_left_door -> Close
OnEndTouchAll -> door_right_door -> Close
Congratulations. Your finished. Save and load your map. Your door will now open and close when you walk on it!

Warning: The movement directions for your door may vary depending on which way youre door is facing. If your door doesn't appear to move or moves in a weird direction adjust your move directions.
Any ideas? lol
I have no entity weapon_portalgun on the list of entities. Also, viewing the weapons directory in the model viewer, the file selection dialog only shows the .jpgs, none of the .mdls.
Also, opening the .mdls in an older stand-alone version of HLMV causes it to crash. (This may or may not be because of its advanced age.)
I've tried re-extracting from the GCFs, and neither HLMV or Hammer wants to play ball. Any ideas?
Thanks again, sleeper and especially NullSoldier.
Couple of notes:
-Make sure you set the Physics Objects flag on the trigger multiple so your weighted companion cube can active the button.
-Likewise uncheck the touch opens flags on the func_doors to prevent the player just walking through your doors without pressing the button.
One thing I did notice is the official buttons light up when pressed, but I have thus far been unable to replicate this.
I'll also write a tutorial for overlays explaining how to change the door textures making them appear as if they have "lit up". Just wait a bit more i'll be writing more tutorials but I work quiet a bit so I can only work on them during the night time.
Part 03 will contain information on creating cube droppers.
NullSoldier wrote:
Part 03
You sir, are a machine.
...when will the wiki be opened? 
y-aji wrote:
for some reason, my doors, after creating this setup, you can still walk up to and open by being in front of them, is there something i have accidentally enabled?
On the door_left_door func_door uncheck the touch opens flag, same for the right one. This is the default door behaviour that needs to be disabled.
Q-
Ralph wrote:
y-aji wrote:for some reason, my doors, after creating this setup, you can still walk up to and open by being in front of them, is there something i have accidentally enabled?
On the door_left_door func_door uncheck the touch opens flag, same for the right one. This is the default door behaviour that needs to be disabled.
ah... you guys always make me feel so dumb to not have checked simple stuff.. Sorry, and thank you.
my doors don't open :*((((((((
Like i did it all correct, but then when i started it up, i go on the button, it dosen't open but it makes the noise. I can walk through it, but it dosen't show it open! zombler. also when i walk up to the door it will open, but the doors don't open on my screen and i can walk thru a wall that is suppose to be there.
some 1 help pl0x k thxs
DiddyKong42 wrote:
GRRRRRRRRRRRRRRRRRmy doors don't open :*((((((((
Like i did it all correct, but then when i started it up, i go on the button, it dosen't open but it makes the noise. I can walk through it, but it dosen't show it open! zombler. also when i walk up to the door it will open, but the doors don't open on my screen and i can walk thru a wall that is suppose to be there.
some 1 help pl0x k thxs
send me your base file and i can see why. I was having alot of frustration with that, yesterday.
Well like now, I just go straight through my door.... i hate this... I even tried copying one and just using it as an prefab. but it still dosen't work...
very frustrating...