Level Design Introduction/Your First Level (Portal 2)

From Valve Developer Community
Jump to: navigation, search
English Русский



  1. 在左边的Tool工具栏中, 选择Hammer block.png Block Tool.
  2. 然后,在Top 2D view(顶视图)中,单击左键并向右下拖动。如图所示。
  3. 你应该可以看到你拖动出来的一个虚线的矩形框。
  4. 创建一个512x512单位大小的方块.
  5. 按键盘上的 Enter 键创建出brush。

回到选择模式:点击工具栏上的Hammer select.png Selection tool 图标或者按 Esc 键.





默认网格大小是64单位, 也就是说线之间的间隔是64单位。当前网格大小在Hammer窗口的下面状态栏中显示着。

  • 点击 Smaller Grid 图标 Hammer SmallerGrid.png 使网格缩小一倍。也可以用 [ 键调整。
  • 点击 Larger Grid 图标 Hammer LargerGrid.png 使网格放大一倍。也可以用 ] 键调整。

[ 键两次,使网格缩小到16单位。确保Hammer窗口状态栏中显示的是Grid: 16。如果不是的话,按 [] 键来调整。







你可以移动创建出来的brush。选择 Selection Tool Hammer select.png (选择工具),鼠标移动到2D视图中的brush上。光标会变成一个四方向箭头FourArrows.png,以表示可以移动物体。



  1. Tools 菜单选择 Options,出现 Configure Hammer 对话框。
  2. 选择 2D Views 面板.
  3. 设置选项有很多,无视之。选中 Arrow keys nudge selected object/vertex
  4. OK 确认。

现在把这个地板brush,在Side视图中向下移动16单位。(按 Down_arrow 一次)

Note:You'll need your ground plane on the same level as the origin line so that the nav file included will work.


  • 滚动条可以平移视图。
  • 更好的方法是,按住 Space 键,单击左边并拖动来平抑。
  • 使用鼠标滚轮来缩放。


要在3D Camera视图中看到贴图, 右击3D Camera视图上 camera 文本,选择 3D Textured

在3D Camera视图中选择3D Texture模式

在3D Camera视图中导航


  • 按住 Space 键,并拖动鼠标左键旋转镜头。
  • 按住 Space 键,并拖动鼠标右键,用来上/下左/右移动镜头。
  • 按住 Space 键,并同时按住鼠标左右键进行拖动,来前/后'移动镜头。
  • 按住 Space 键,时也可以用 W, A, S, 和 D 键,来移动镜头。
  • Z 键,用来开关 "mouse look" 模式。切换到3D Camera视图,并按下 Z 键。就可以像在游戏中那样用鼠标控制镜头了。
Note:The W A S D keys can be used in combination with the Space navigation

3D Camera 视图中向上移动,并查看你刚才创建的地板。

The Browse button on the Texture bar.

你会看到地板的贴图是默认的。 改变贴图的方法是,点击在 Texture 面板的 Browse按钮。

会打开 Texture Browser 窗口。
The generic gray developer texture.

在底部的 Filter 栏,可以按照名字来过滤贴图。在这个教程中,输入 "dev_measure"(包含下划线)。就会有一堆“开发者”贴图,来辅助创建东西。

选择 dev/dev_measuregeneric01b 并双击。

Applying the current texture to the selected brush.

This should bring back the 4 viewports of the editor and place the generic developer texture as the current one in the Texture bar.

Select the floor brush, if it isn't already selected, by clicking on it in the Camera viewport. It should turn red.

After the brush is selected, click on the Hammer ApplyCurrentTexture.png Apply current texture icon on the Tool bar to apply the current texture to the selection. The gray developer texture should appear on the floor as shown.


Now let's go over how to create the walls and ceiling of the room. The easiest way to do this is to duplicate the floor brush.


You can also select an existing brush and duplicate it to create them.

Note:To duplicate, you will need to have the Arrow keys nudge selected object/vertex option set if you didn't do this earlier in the tutorial. You can find it under Tools > Options > 2D Tab.
Duplicating brushes to make a room.

To duplicate:

  1. Select the floor brush that you've created.
  2. Move your cursor over the Side viewport.
  3. Hold the Shift key down and press the Up_arrow key to create a duplicate and move it up 1 grid unit.

This will create a brush exactly like the floor on top of the existing floor.

You can now change the size and dimensions of this new brush to create a wall grabbing the corner handles on the brush and dragging it to the size you wish. Let's make the wall 128 units tall and 16 units thick.

Tip:To move the brush you created, using the arrow keys or simply click and drag inside the center of the brush to drag it to another location.
Now duplicate the wall 3 more times to outline the floor.
Duplicating the floor to create a ceiling.

Duplicate the floor brush 1 more time and raise it to become the ceiling.

Tip:Keeping your level clean will become very important when you start to run it in the game. It's a good idea not to have overlapping brushes (brushes that intersect one another). This can cause "z-fighting" in the game, which is where multiple faces fight to get drawn over one another.


To delete a brush, select it with the Selection Tool Hammer select.png and press the Delete key.


Applying the generic orange developer texture to the walls.

You'll notice that in the Camera viewport, if you navigate inside the room, it's hard to tell what's going on because all of the walls, floor and ceiling are the same texture. Next we'll change the walls to a different texture.

You can select all of the walls by holding down the Ctrl key and clicking on them one at a time in the Camera viewport. You will have to use the SPACE camera controls to rotate the camera around so you can select each wall.

After you have all of the walls selected, click on the Browse button in the Texture bar. This time, select the orange texture next to the current one, labeled dev/dev_measuregeneric01. Double-click it to select it and close the browser window.

Use the Hammer ApplyCurrentTexture.png tool on the Tool Bar to apply the orange texture to the walls.


To save a level, you can use Ctrl+S or Save from the File menu.

You will need to give the map a file a name and choose the directory to place it in.

For this tutorial, name the map "tutorial01" and save it into the mapsrc directory, located by default at:

C:\Program Files\Steam\steamapps\common\portal 2\sdk_content\maps\

Your directory may be slightly different, depending upon where you have installed Steam.


When you went to save your map, you may have noticed other directories underneath the mapsrc path. The Portal 2 Authoring Tools come with some example maps to help you.

Directory Contents
maps\mp_coop_doors Coop map.
maps\mp_coop_paint_red_racer Coop map with Propulsion Gel.
maps\sp_a2_column_blocker Single Player map with Bridges.
maps\sp_a2_trust_fling Single Player map with Aerial Faith Plates.
maps\sp_a3_speed_ramp Single Player map with Propulsion Gel.
maps\sp_a4_laser_catapult Single Player map with Tractor Beams, Lasers and an Aerial Faith Plate.
maps\zoo_mechanics Contains most of the the gameplay mechanics used in Portal 2.


Selecting the entity.
Placing an info_player_start.

Next we'll place an entity in our level:

  1. Select the Hammer entity.png Entity Tool on the Tool Bar.
  2. Once the Entity Tool is enabled, the Entity selection list on the Object bar becomes active.
  3. Keep the Categories entry as Entities.
  4. Click the arrow on the Objects drop down list and select info_player_start.
  5. Now, navigate in the Camera viewport to the middle of the inside of the room.
  6. left-click on the floor to place the entity.
This will place an info_player_start entity in the middle of the room.

放置一个 light

Now we'll place a source of illumination in the map:

  1. Select the Entity Tool again
  2. Select light from the Objects drop down list on the Object bar.
  3. This time, place the light on the ceiling (above the player's head).
  4. Go back into selection mode by clicking on the Hammer select.png Selection tool in the Tool Bar or by pressing the Esc key.
The Object Properties for a light.

Next we'll change some settings on the light. Bring up the light's properties by double-clicking it in the Camera viewport or by selecting it (left-clicking on it) and then pressing the Alt+ Enter keys. This will bring up the Object Properties dialog box.

From the Object Properties, you can change various properties of the entity. For example, you can change the Brightness of this light. Click on the Brightness row under Keyvalues and you will see a set of numbers on the drop down menu on the right side. The default setting for the brightness of a light is 255 255 255 200. The first three numbers represent the RGB values (color) and the last number represents the intensity of the light.

You can click on the Pick Color button to select a color rather than input values for it.
Picking a color for a light.

Simply click on the color you want the light to be and click OK.

This will bring you back to the Object Properties dialog box for the light. You should see any changes you made to the brightness on the Brightness row and the drop down field on the right side if the Brightness row is selected.

Click the Apply button to set your changes to the entity and close the dialog box by clicking on the "X" at the upper right side of the window.

放置一个 prop_static

The Object Properties for a prop_static entity.

Entities also consist of props like furniture, decoration, and complex parts of architecture. There are a variety of different kinds of props. Prop_static entities are props that are static – they don't move, animate, turn on or turn off. There are also prop_dynamic entities that can move, animate, be enabled and disabled. There are also prop_physics entities which the player can interact with and behave physically as they would in the real world.

To place a prop:

  1. Select on the Entity Tool again.
  2. Go to the Object bar and change the Objects field to prop_static.
  3. Point to the floor in front of the model of Francis and left-click to place a prop_static. You will see a red cube that represents the prop_static before a model is attached to it.
  4. Go back into selection mode by clicking on the Hammer select.png Selection tool in the Tool Bar or by pressing the Esc key.
  5. Double-click on the red cube to open the properties.
  6. Double-click on the World Model field to open the Model Browser.
Warning: The first time that the Model Browser window loads, it can take a while to load in all of the models. It might not immediately look like the image you see below. If you cannot find the model you're looking for, give it a minute to finishing loading.

Selecting the model

Selecting the table model in the Model Browser.
  1. In the Filter field at the bottom of the dialog box, type in "paint". This will show all the models that have the word "paint" in their name.
  2. Scroll down to the one named:
    It should look like the image shown.
  3. Click OK to select it and close the browser and return to the Object Properties dialog box. You should see the name of the model now in the World Model row.
  4. Click the Apply button to set your changes to the entity.
  5. Close the Properties box.
You will see the table that you just placed in the room in any of the viewports in the editor.

移动 entity

You can move entities like our paintdropper the same way you can move brushes. Click and drag inside the bounding box of the selected entity to move it around with your mouse or put your mouse over any of the viewports and use the arrow keys on your keyboard to move them around.

旋转 entity

To rotate an object , you simply select the object you wish to rotate using the Selection Tool Hammer select.png, then click once on the object. You should see the object surrounded at the corners with circles. Mouse over a circle in any 2D view, then click and drag to rotate the object.

Use your mouse wheel to zoom into the Front viewport and click once inside the bounding box of the paintdropper model to make its four corners highlight with circles around each one.

Left-click and drag in a counter-clockwise motion to rotate the paintdropper so that it can drop paint from the ceiliing.


Change the Run Map parameters to match these settings, then click OK.

You have saved your map, but you will also need to compile it before it can be played in the game engine.

When a map is compiled, it is converted from the raw .VMF file that you just saved, into the .BSP format used by the game engine. The geometry is processed and the proper lighting and shadows are pre-calculated with several compile programs.

  • Open the File menu, and choose Run Map... or press the F9 key.
  • The Run Map dialog will open.
  • This dialog is used to set some basic compile parameters.
    1. Make sure that Normal is set under the Run BSP, Run VIS, and Run RAD settings.
    2. Under Additional game parameters:, make sure these settings are present, and type them in if not:
      -toconsole -dev -console +sv_lan 1
    3. Now click the OK button to start the map compile process.

The Compile Process Window will show the progress of the compile. When the compilation is done, the game you are mapping for will automatically launch, and load your map in the engine.

Note:If you wish to compile with High Dynamic Range lighting, simply check the box that says HDR. The time to compile the map will be twice as long, but that is completely normal.

Your level in the game should load up after compiling. It may take a minute or two.

Running the level in the game.


Making levels for Portal 2 sometimes involves using commands typed into the Developer Console window. The console can also be used to do things like spawn cubes and turrets to test your level.

Enabling the developer console.

If you haven't already, make sure the console is enabled in the game:

  1. Press the Esc key in the game.
  2. Click on Options, then Keyboard/Mouse.
  3. Click on the Allow Developer Console and select "Enabled".
  4. Click on the Done Button.
  5. Click on Return to Game.

Using the developer console:

  1. Bring down your developer console ` (tilde).
  2. Type any console command and press the Enter key.
  3. Hide the console again with `.


One console command you'll find constantly useful is noclip mode. This is a mode that let's you fly around the level without being stopped ("clipped") by anything in the level. It's useful to get around large levels quickly.

To enter noclip mode:

  • Press ` to enter the console.
  • Type noclip in the console and press Enter.
  • Fly around the level.
  • Type noclip again to leave noclip and walk around the level normally.
  • You can toggle noclip with the press of a button with the bind console command. For example, bind mouse3 noclip for the middle mouse button.



sv_cheats 1
map <地图名>
changelevel <地图名>
god 1

Level Design Introduction
Getting Started