Please or Register to create posts and topics.

Guide to Portal Hammer Button + Door Part 2

Page 1 of 3Next

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.

Image

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.

Image

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.

Image

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".

Image

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

Image

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".

Image

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!

Image

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.

Portal: Quest for Cake: 5%
[img]www31.brinkster.com/taob1/Signiture2.bmp[/img]

Here is the finished example map. I had some real issues with movement direction. Annoying.

Portal: Quest for Cake: 5%
[img]www31.brinkster.com/taob1/Signiture2.bmp[/img]

Stickied. Another great thread. When I get the wiki up and ready to go, think you would mind porting this information over to that?

[Important Threads] Forum Rules | Welcome to the new Thinking With Portals
Please do not Private Message me for assistance. Post a thread if you have questions or concerns.
If you need to contact the staff privately, contact the Global Moderators via Discord.

Now, if i can just figure out how those combine ball launchers work, i think i'll be equipped with everything i need to be really creative!

Any ideas? lol

There are some point entities that control ball_launch'ing and ball_catch'ing. Keep in mind that the models are just prop_dynamics that are controlled via the entities, much like the buttons.

[Important Threads] Forum Rules | Welcome to the new Thinking With Portals
Please do not Private Message me for assistance. Post a thread if you have questions or concerns.
If you need to contact the staff privately, contact the Global Moderators via Discord.

New tutorial part, new bug.

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?

"Games are made out of smaller games ? turtles all the way down, until you hit the game that is so trivial and stupid it isn?t deserving of the name." --Raph Koster

Sounds like you don't have the FGD loaded? Not sure about model viewer crashing, but that could be why you don't have the entities in Hammer.

[Important Threads] Forum Rules | Welcome to the new Thinking With Portals
Please do not Private Message me for assistance. Post a thread if you have questions or concerns.
If you need to contact the staff privately, contact the Global Moderators via Discord.

Yeah, I never loaded the FGD. I didn't follow the paragraph in the tutorial that told me to do that. (I interpreted "Now the final step is easy" as "Skim this last paragraph and sort of do what I said")

Thanks again, sleeper and especially NullSoldier.

"Games are made out of smaller games ? turtles all the way down, until you hit the game that is so trivial and stupid it isn?t deserving of the name." --Raph Koster

Good work.

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.

Only a spider trusts the web

Yes, i'll port the information over. As for the previous suggestions, I was going to explain the "physics" flag in the trigger when I write my next tutorial explaining the cube dropper.

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.

Portal: Quest for Cake: 5%
[img]www31.brinkster.com/taob1/Signiture2.bmp[/img]
Page 1 of 3Next