Beginner Portal Map Tutorial:es
From Valve Developer Community
| Spigot 37 | |
|---|---|
| |
| Created | March 2009 |
| Last Update | March 2009 |
| Author | Rigor Mortis |
| Links | |
| Spigot 37 | |
Contents |
Building your first Portal map with Hammer.
Contents
This won't be a fancy map, but I will teach you the following:
- Creating simple level geometry with brushes.
- Reducing visleafs/optimizing level geometry.
- Creating/placing props (level entry, signs, boxes, companion cubes)
- Triggering events
- Parenting
- Setting portal-able/non-portal-able surfaces and Portal bumpers
- Fixing leaks / finding problems
Things I won't be teaching in this:
- How to make a pretty Aperture Science door.
- How to make a 1500 Megawatt Aperture Science Heavy Duty Supercolliding Super Button. There are already good tutorials for that.
This is just the nitty gritty of building a level.
Tools Summary
Before we get started, let's cover the tools Hammer has to offer.
Left Side Toolbar
Right Side Toolbars
At the top you should have this box, which allows you to pick what you want to be selecting. To a new editor, Groups is fine to leave it on.
Next you have the Texture's box, which shows your currently selected texture.
Below that is your Filter Control, which will be explained later (and is VERY useful).
Bottom Info Bar
At the very bottom of the screen, there is some information listed. The current cursor location is down there, as well as the Zoom level and the Grid size and whether "Snap" is enabled for the grid.
- As a side note, Hammer works in inches (approximately), so you can think of its units as inches... just remember that.
Creating a Room
OK, now that we've briefly covered the tools of the trade, Let's get down to making a map!
Open a new map.
Use the bracket keys [ ] to change your grid size to 8 (which is what we will use to build walls).
Hover your mouse over the upper right viewpane, which should be your "Top x/y" view and hold down the space bar, then click (space+click) then move the mouse around.
See how you can pan around? That's how I move my views instead of using the camera tool. you can do this in any view. Also try zooming in and out with the mouse wheel to get a feel for how that works.
Look for the blue/green lines on the grid. Those show your origin. While it isn't important to stay at the origin for any reason, I like to start building there.
Select the "Block Tool" and ensure that the menu on the bottom right shows "Primitives" and "Block"
Click and drag in the Top view to create a tall thin box (this will be a wall, so 8" thick by 512" long).
Choose either the front or side view (it doesn't matter which) and drag the square by the top handle to be about 512" high.
Once you have the wall the way you want it in all 3 views, press Enter. The wall has now been 'made.' Don't think that making this wall sets it in stone though! You can move and change it many ways, as in the next section.
I want you to get a feel for moving the camera around now, so let's look at the 3d view for a moment.
Hover your mouse over the 3d view and then space+click like you did to pan the other views. Moving the mouse changes your view just like when you're playing portal as long as you keep that mouse button held (you can let go of the space bar).
While you are doing this, you can press W, A, S, and D to move your camera around. This is a great way to quickly navigate your maps.
- * * * If you can't see a texture on your wall, change the 3d view setting to "Textured"
So, now that you have a wall and can navigate, let's finish this room.
Select the "Selection Tool" and then select your wall in the 3d view (it will highlight red/yellow in all views).
Hold shift, then select your wall in the top view with the mouse and drag it over to the right, then release the mouse while holding shift. This performs a "Copy" operation.
Now you have two equivalent walls, but no top/bottom walls and no ceiling or floor! Let's have some fun making those.
Select a wall and copy it (just like before, hold shift and drag the wall) to the middle of the two walls.
While that middle wall is selected, right click on it in the top view and select "Transform"
Choose "Rotate" and enter 90 in "Z" then press enter or choose OK.
Now select/move your wall into place as the top wall.
At this point, many new mappers will wonder how you should overlap (or not overlap) level geometry. To make things look good and work well, you really shouldn't physically overlap them... but they should meet up as illustrated here:
Try to avoid having corners meet, as this can create "leaks" - which are a big pain in any mappers butt (I will illustrate a leak for you before this is over).
Ok, on to the bottom wall. We could just copy the top wall, but lets try something different. Copy one of the side walls to the middle again. Now, while it's selected from the top view, use the corner handles to resize the wall into the bottom wall. Using this simple technique, you can avoid having to create new objects from the Block Tool all the time, which will save you lots of time and effort when making complex maps!
Now, using the same technique, go to the side view (just below the Top view) and copy one of the walls up a bit, then resize it to be the ceiling. The easiest way in my opinion is to copy a wall up one block (8 inches) then use the bottom corner to resize it to be an 8" thick ceiling.
- Just to let you know, this 8" thing is arbitrary. You could make 1" thick walls, but I prefer 8" because they are easier to see and work with. Also, when you start doing detail work, you can use 1" for that and 8" for major level contruction.
Now, you have the ceiling... it should be the same as the floor, so just copy it down to the bottom from a side view.
Now, you have all six sides of a room. So, are you ready to hate me yet? Select all of the walls of your room by doing the following: Move your camera in the 3d view to inside the room. Select a wall, then hold "shift" while you select all the others. Got them all selected? Press "Delete"
Wow... that sucks, it's all gone. Don't worry, it'll be back in no time.
Go to the Block Tool and make a block 512 x 512 x 512
Once this block has been created (remember to press enter to create it), go back to the selection tool and right click on it in any of the side/top views. Select "Make Hollow" and enter -8 for the thickness, then press enter.
That was wicked fast... so why did I make you do all the other stuff? Hopefully you learned some good tricks to build nifty stuff later on.
So, now that we have this room, try to select just one wall. Having troubles? You see, these walls are all grouped because of the 'make hollow' command. You have two options here. Either go up to the right corner and change your Select mode to "Objects" or ungroup the walls with Ctrl+U - either is fine.
Groups are a great thing when you want to be able to quickly copy/move/edit many things together (like a complicated room, or a set of stairs that are really cool and might look good in that next chamber...) I usually leave the Selection Tool on "Objects" unless I need to use one of the other modes for something.
Creating Entities
Now that this map has a room, let's get a feel for how big it really is. Use the 3d view to position your camera inside the room and aim at the floor.
Entity Tool
Select the Entity Tool
In the bottom right corner it should already have changed to 'Entities' and info_player_start - if not, change it to these settings.
Now, inside the 3d view, click on the floor of your room. A little green person should now be standing on the floor of your room.
This is where the player will start in your map, so you may want to use the Top view to move him around. Also, he might be looking the wrong direction for you right now.
You can adjust this by selecting him with the Selection Tool, then selecting him again. Se how the handles change to circles? Now you can rotate him by using the handles.
- I would highly recommend against using the handles to rotate world geometry since it is not a very exact angle you end up with. Only use this for entities and detail work.
Now that you have a player start in your map, you are almost ready to compile it for the first time, but before we do that, let's add two more things.
Select the Entity Tool again.
Change the entity from info_player_start to weapon_portalgun.
Click in the 3d view just in front of your player start's feet to place the portal gun. I recommend moving it under the player start so the player starts automatically with the gun, but that isn't necessary - just convenient.
Now we need a light source. Technically, you can compile this map right now and play it, but everything would be very bright, and anyone who has mapped for a while will tell you that mat_fullbright 1 can be a real pain.
Add a light
Change your entity from weapon_portalgun to Light and stick a light in the middle of the ceiling of your map.
Select the Selection Tool (Shift+S) and double click on your light in the 3d view. This brings up the properties menu.
You can change many things about entities in this window. For now, we are just going to edit this light's brightness.
Select the Brightness/color item in the properties window. On the right side you should see 255 255 255 200
The first three items are colors of light - Red, Green, Blue. Currently they are all on full, which means a white light.
The last item is the brightness of the light, which is currently 200. You can have lights as bright as you like (I've never tested the upper limit of this) but I personally think 200 is too bright.
Let's change this one to 50. Click "Apply" in the properties window to save your change and close the properties window.
Create an entity from a world brush
First, select the info_player_start in your level with the selection tool.
Select the Block Creation Tool and choose "cylinder" instead of "block" on the right side "Objects" menu.
Now draw a square, 16x16 from the top view. Do you see how it matches the height of the entity you selected in the side views? You can do this to make sizing new objects easier. It even works if you select multiple objects.
Now press "enter" to create that cylinder. You can increase the number of sides (if you do, make your grid smaller with [ ] )
Select the cylinder and press Ctrl+T Just leave it as a func_detail for now. We will get into other types of entities later.
You have now officially created an entity from a world brush.
First compile
Now you have a room that can be played in Portal. Save your map as "Spigot_Tutorial01", then press F9 to bring up the Compile Process Window.
Select:
Run BSP: Normal
Run VIS: Fast
Run RAD: Fast
Check 'Don't run the game after compiling'
Click Compile.
This should go REALLY fast for this map, since it's only 1 visleaf and 1 light.
Now, minimize Hammer, and open Portal (you should get used to having both of these open at the same time... it's important to be able to switch back and forth sometimes)
Open the Console and type map Spigot_Tutorial01 and press Enter.
You should now be standing in the room you made with a portal gun in your hands. Neat, huh? Yeah, so you still have a long ways to go before you can make good maps, but this is a good start.
Before you tab out of or quit Portal, go back into the console and type bind "i" "disconnect"
Go back to the game and press i. It should dump you back to the menu screen. You should ALWAYS disconnect before tabbing out of your map to go back to hammer to do work. This keeps the game or Hammer from crashing due to runtime errors.
- If you don't know what 'tabbing out' means - try pressing alt+tab any time you're in windows. It will let you switch between running programs quickly.
Texturing
This is perhaps the easiest part of making a map, but can take the longest to do. Select the 'Toggle Texture Application' tool. A window should open.
This window is where you can select, copy, stretch, move, and change textures. With the window still open, select a wall of your room in the 3d view.
The selected polygon will be highlighted. Take note that by clicking you are selecting just one side of the solid for that wall.
If you want to select all 6 sides, hold Shift while clicking on the wall.
You can also select multiple polygons on different objects with Ctrl. You can also select multiple complete objects with Ctrl+Shift
To change the texture, select "Browse..." by the texture picture in the Texture Application Window.
This brings up a long list of textures you can choose from. At the bottom, the 'filter' field will allow you to enter things like "metal" or "concrete" to easily sift through the thousands of textures available to you.
Select a new texture for your wall, and double click it to choose it. Now click apply, and you will see it pasted on your wall.
Copy textures
Once you have a texture in your level, it's very easy to copy it.
Just select a polygon with the texture you want to copy.
Now right click on everything you want to copy that texture to. Easy, right?!
Selecting textures
It may seem like a no-brainer, but selecting textures can be problematic. Some textures are reserved for tools, others for models, and still others for animations.
The two biggest problems you can encounter with textures are: using a model texture on a world brush, and using a tools texture where you shouldn't.
Open the Texture Browser by opening the Texture Application (Shift+A).
Enter 'tools' into the filter field at the bottom of the screen.
Now you should have a list of textures that are all special tools. Each has its own use, which is outside the scope of this tutorial, but if you want to learn about one, just select it and search for the name of it on the VDC.
Leaks
A leak is a place in your level where, as a player, you could see into the 'nothingness' outside your playable level area. Hammer finds leaks by trying to draw a line from any entity inside your map into the empty space outside your map. If it succeeds, it shows an error "**** leaked ****" in the compile process window and saves the leak information in a pointfile. Leaks will cause your map to compile incorrectly, so do your best to avoid having any of them.
- Another way to think of a leak is to imagine that you pumped your level full of water. A leak would be any spot where water could get out of the level.
Finding Leaks
To find a leak, we need to add a leak on purpose to your level.
Select your ceiling in the top view, now make it about 3/4 of its current width. If you were to stand inside the room, you would now see a huge gap in the ceiling.
Compile your map as normal.
Now, when the compile process finishes, scroll up to the top of your compile process window and look for the "**** leaked ****" error. I usually check this every time I make any changes to the structure of my level, just to make sure I didn't have any leaks.
Now that you determined you have a leak, finding it is easy.
Close the compile process window. Go to the top menu Map > Load Pointfile
Select Yes - you do want the default pointfile to be loaded.
Now, go into your 3d view and look around. You will find a red line protruding from your map. Following this line will show you exactly where the leak is.
Fixing Leaks
Generally speaking, fixing a leak is as simple as fixing your level geometry. Sometimes you might move a wall to make it shorter and forget to fix the ceiling to match, or you might make a hallway shorter and one wall gets a little shorter than the others. These things happen.
If you get a leak somewhere and you want the level geometry to stay the way it is, you can enclose the area in geometry textured with NODRAW texture. I call them NODRAWs. NODRAWs will close up a leak, but will not be rendered, so things will look the way you wanted them. Be careful with this, as it is only really useful in certain situations.
As an example, in our maps we have points in the map where a player can see into a hallway, but can't get into it, so once we get to a part of the hallway the player can't see (like around a corner), we stick a big NODRAW to plug up any leaks.
Visleafs
Read here before continuing to discover what a VisLeaf is.
Confused yet? Well, don't worry... it's a lot easier to show you what a visleaf is than to tell you. Let's use the room you have to make some visleafs so you can see them in Portal.
You remember that pillar we put in the middle of your room? I want you to select it, then click the "toWorld" button on the right side of your Hammer window. This deletes the entity we made earlier to keep that cylinder from cutting up your room into visleafs. Now we can recompile your map and take a look at some VisLeafs!
Before compiling, zoom in and adjust the bottom of the cylinder from the side to make sure that the cylinder is touching the floor.
Then go ahead and compile your map, just like last time.
Open the console once you have opened your map and are walking around the room looking at a little pillar and type in mat_leafvis 1 and press enter. Go back to the game.
See the red outlines? In a room this size, you should have anywhere from 1 to 4 visleafs. Walk around the room and see how many you have here. Remember that the space above the cylinder has visleafs as well. If you jump or portal up there you can get inside those visleafs and see them, too.
Go ahead and disconnect and get back into hammer.
So, why did I show you this? Imagine you decide to build a desk in Hammer. How many visleafs would that create in your room? Even a simple object can add a TON of visleafs. This is why it is highly recommended to turn any objects that are not separating or outside walls into func_details by selecting them and pressing Ctrl+T.
There is an excellent article on VisLeaf reduction here
As a map designer, you need to be aware of how your level construction will create VisLeafs, since the more VisLeafs you have, the longer the time it will take for your map to compile. In fact, if you make too many VisLeafs, your computer might never be able to finish compiling a complex map!







