Your First Portal Level: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Created page with "{{LanguageBar|Level_Design_Introduction_(Portal_2)/Your_First_Level|title=你的第一个关卡(Portal 2)}} {{back | Category:Zh/Portal 2 Level Design|Portal 2关卡设计介绍}} {{Portal 2 level intro menu}}__TOC__ ''{{L|brush}}''(刷子)是在Hammer中用'''Block'''工具创建的3D物体。Brush用来创建天花板和地板之类大块的表面的。我们将使用brush来创建一个房间。 == 用brush创建地板 == File:l4d_hammer_brush_01.jpg|thumb...")
 
(Rewrite Template:Lang to Template:LanguageBar. This action was performed by a bot.)
 
(15 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{LanguageBar|Level_Design_Introduction_(Portal_2)/Your_First_Level|title=你的第一个关卡(Portal 2)}}
{{LanguageBar|title=Level Design Introduction/Your First Level|Level Design Introduction/Your First Level}}
{{back | Category:Zh/Portal 2 Level Design|Portal 2关卡设计介绍}}
{{Portal 2 level intro menu}}__TOC__
''{{L|brush}}''(刷子)是在Hammer中用'''Block'''工具创建的3D物体。Brush用来创建天花板和地板之类大块的表面的。我们将使用brush来创建一个房间。


== 用brush创建地板 ==
{{Note|This article was modified by [[User:WoShiGeNiCheng|WoShiGeNiCheng(我是个昵称-hello)]] by modifying the article Portal 2 to create the first level, and it will be removed if it is infringing(probably not).}}
[[File:l4d_hammer_brush_01.jpg|thumb|right|400px|caption|绘制一个brush.]]
{{Note|Since not many people learn Hammer from the first generation of Portal, it is recommended to start from the second generation.[[Level_Design_Introduction_(Portal_2)/Your_First_Level|Your First Level(Portal 2)]]}}


# 在左边的'''Tool'''工具栏中, 选择[[File:Hammer block.png]] '''Block Tool'''.
A ''[[brush]]'' is a simple 3D shape created with Hammer's '''Block''' tool. Brushes are used to created the majority of large surfaces in your level, such as ceilings and floors. We will now create a simple room using brushes.
# 然后,在'''Top''' 2D view(顶视图)中,单击左键并向右下拖动。如图所示。
 
# 你应该可以看到你拖动出来的一个虚线的矩形框。
== Creating a floor brush ==
# 创建一个512x512单位大小的方块.
[[File:l4d_hammer_brush_01.jpg|thumb|right|400px|caption|Drawing a brush.]]
# 按键盘上的 {{key|Enter}} 键创建出brush。
 
# From the '''Tool''' bar on the left, select the [[File:Hammer block.png]] '''Block Tool'''.
# Now, left-click and drag in the '''Top''' 2D view in a movement that is ''Right'' and ''Downward'' as shown below.
# You should see a dotted outline of a rectangle or square as you drag.
# Create a square 512x512 units and let go of the left-mouse button.
# Press {{key|Enter}} on your keyboard to create this brush that you've just drawn.


{{clr}}
{{clr}}


回到选择模式:点击工具栏上的[[File:Hammer select.png]] '''Selection tool''' 图标或者按 {{key|Esc}} .
To go back to selection mode, click on the [[File:Hammer select.png]] '''Selection tool''' icon on the '''Tool''' bar or press the {{key|Esc}} key.


在选择模式中,选中刚才的那个brush,左键单击边缘的小方块可以改变brush的大小。
In selection mode, with the brush selected, you can change the size of the brush by left-clicking on any of the boxes that appear on the borders of the brush and dragging them out or in.


现在我们来调整这个brush的厚度(为了用来做地板),从'''64'''单位调整到'''16'''。但首先要调整grid(网格)的大小。
Let's decrease the thickness of the brush (which we'll be using as a floor) from the default '''64''' units to '''16'''. To do this, we need to change the size of the grid.


=== 关于网格 ===
=== The grid ===
grid出现在每个2D视图。默认情况下,任何物体都会对齐到网格(grid)。虽然你可以关闭对齐到网格,但是还是留着比较好,以防止在地图中出现泄漏(leak)之类的错误。
A grid is displayed in all the 2D views. By default, all objects snap to the grid. Although you can turn this off, it is considered good practice to leave it on because it prevents leaks and other errors in your map.


默认网格大小是64单位, 也就是说线之间的间隔是64单位。当前网格大小在Hammer窗口的下面状态栏中显示着。
The default grid size is 64 units, which means that each line is 64 units apart. The current size of the grid is displayed in the status bar at the bottom of the Hammer window.


* 点击 '''Smaller Grid''' 图标 [[File:hammer_SmallerGrid.png]] 使网格缩小一倍。也可以用 {{key|[}} 键调整。
* Clicking the '''Smaller Grid''' icon [[File:hammer_SmallerGrid.png]] will make the grid half as big, for finer adjustments. You can also decrease the grid size with the {{key|[}} key
* 点击 '''Larger Grid''' 图标 [[File:hammer_LargerGrid.png]] 使网格放大一倍。也可以用 {{key|]}} 键调整。
* Clicking the '''Larger Grid''' icon [[File:hammer_LargerGrid.png]] will make the grid twice as big, for larger adjustments. You can also increase the grid size with the {{key|]}} key.


{{key|[}} 键两次,使网格缩小到16单位。确保Hammer窗口状态栏中显示的是'''Grid: 16'''。如果不是的话,按 {{key|[}} {{key|]}} 键来调整。
To bring the grid size down to 16 units, press the {{key|[}} key twice. Look at the '''Status bar''' at the bottom right of the Hammer window and make sure it reads '''Grid: 16'''. If it doesn't, press {{key|[}} or {{key|]}} until is does.


=== 调整地板的大小 ===
=== Resize the floor ===
[[File:l4d_hammer_brush_02.jpg|thumb|right|400px|caption|在侧视图中降低brush的高度。]]
[[File:l4d_hammer_brush_02.jpg|thumb|right|400px|caption|Lowering the height of a brush in the Side viewport.]]


现在网格应该足够小了。
Now the grid should be small enough.


看右下方的视图。鼠标移上去的时候,应该显示'''Side'''标签。拖动brush的上边缘,令它的厚度为16单位。{{clr}}
Switch to the bottom right viewport. It should be labeled '''Side''' when you mouse over it. Drag the top border of the brush down so that it's 16 units thick.{{clr}}


=== 移动brush ===
=== Moving brushes ===
[[File:hammer_movingBrushes.png|thumb|238px|right|在2D视图的点击并拖动来移动brush。]]
[[File:hammer_movingBrushes.png|thumb|238px|right|Click & drag in any 2D view to move a brush.]]
你可以移动创建出来的brush。选择 '''Selection Tool''' [[File:hammer_select.png|28px]] (选择工具),鼠标移动到2D视图中的brush上。光标会变成一个四方向箭头[[File:fourArrows.png]],以表示可以移动物体。
You can move brushes around once they're created. Select the '''Selection Tool''' [[File:hammer_select.png|28px]] and mouse over the brush in one of the 2D views, staying clear of the corner handles. The pointer will change into four arrows pointing in all four directions [[File:fourArrows.png]], indicating the option to move the object.


在2D视图中点击并拖动brush。一旦释放,brush就移动到新的位置了。{{clr}}
Click and drag the brush to move the brush in any of the 2D views. Upon release, the brush will be moved to that position.{{clr}}


[[File:l4d_hammer_options_2d.jpg|thumb|right|300px|caption|Hammer的选项]]
[[File:l4d_hammer_options_2d.jpg|thumb|right|300px|caption|Configuring the options in Hammer.]]


也可以使用方向键移动物体。但首先要设置一下Hammer的选项,方法如下:
You can also move objects with the arrow (cursor) keys. To do that, we'll need to change a setting in the Hammer options to allow the arrow keys to be used:


# '''Tools''' 菜单选择 '''Options''',出现 '''Configure Hammer''' 对话框。
# Go to '''Tools''' menu and pick '''Options''' to bring up the '''Configure Hammer''' dialog box.
# 选择 '''2D Views''' 面板.
# Click on the '''2D Views''' tab.
# 设置选项有很多,无视之。选中 '''Arrow keys nudge selected object/vertex'''
# There are other settings here as well, but for now, we just need to check the box marked '''Arrow keys nudge selected object/vertex'''.
# '''OK''' 确认。
# Press '''OK''' to confirm the change and close the settings.
{{clr}}
{{clr}}


现在把这个地板brush,在'''Side'''视图中向下移动16单位。(按 {{key|}} 一次)
Now let's move the floor brush down 16 units by placing the mouse cursor over the '''Side''' viewport and pressing the {{key|Down_arrow}} once.


[[File:l4d_hammer_brush_03.jpg|thumb|left|400px|caption|在侧视图中向下移动brush]]{{clr}}
[[File:l4d_hammer_brush_03.jpg|thumb|left|400px|caption|Moving a brush down in the Side viewport.]]{{clr}}


{{Note|您需要将地平面与原点线放在同一水平面上,以便包含的导航文件可以正常工作。}}
{{note|You'll need your ground plane on the same level as the origin line so that the nav file included will work.}}


== 在2D视图中导航 ==
== Navigating in the 2D viewports ==


* 滚动条可以平移视图。
* Use can use the scrollbars to pan the view.
* 更好的方法是,按住 {{key|Space}} 键,单击左键并平移。
* For a faster method, hold down the {{key|Space}} bar and left-click and drag to pan.
* 使用鼠标滚轮来缩放。
* Use the Mouse Wheel to zoom in and out.


== 材质 ==
== Texturing ==
要在3D Camera视图中看到贴图, 右击3D Camera视图上 '''camera''' 文本,选择 '''3D Textured'''
To see textures in the 3D Camera viewport, right-click on the '''camera''' text in the 3D Camera viewport and select '''3D Textured'''.


[[File:l4d_hammer_3DTextured.jpg|thumb|right|400px|caption|在3D Camera视图中选择3D Texture模式]]
[[File:l4d_hammer_3DTextured.jpg|thumb|right|400px|caption|Selecting the 3D Textured mode in the Camera viewport.]]


=== 在3D Camera视图中导航 ===
=== Navigating in the 3D Camera viewport ===


在3D中移动和2D视图中有所不同:
Moving around in 3D is a bit different from the 2D viewports:


* 按住 {{key|Space}} 键,并拖动鼠标左键'''旋转'''镜头。
* Hold down the {{key|Space}} and left-click and drag to '''rotate''' the camera.
* 按住 {{key|Space}} 键,并拖动鼠标右键,用来'''上下''''''左右'''移动镜头。
* Hold down the {{key|Space}} and right-click and drag to move '''up/down''' and '''left/right'''.
* 按住 {{key|Space}} 键,并同时按住鼠标左右键进行拖动,来'''前后'''移动镜头。
* Hold down the {{key|Space}} and both right and left-click and drag to move '''forward''' and '''backward'''.
* 按住 {{key|Space}} 键时,也可以用 {{key|W}}, {{key|A}}, {{key|S}}, {{key|D}} 键,来移动镜头。
* You can also use {{key|W}}, {{key|A}}, {{key|S}}, and {{key|D}} to move '''forward''', '''backward''', '''strafe left''' and '''strafe right''' respectively.
* {{key|Z}} 键,用来开关 "mouse look" 模式。切换到3D Camera视图,并按下 {{key|Z}} 键。就可以像在游戏中那样用鼠标控制镜头了。
* The {{key|Z}} key toggles on and off "mouse look" mode. Move your mouse cursor over the 3D Camera viewport and press the {{key|Z}} key. You can now move your mouse around as if mouse look was on in the game.


{{note|{{key|W}} {{key|A}} {{key|S}} {{key|D}}键可以与{{key|Space}}导航结合使用}}
{{note|The {{key|W}} {{key|A}} {{key|S}} {{key|D}} keys can be used in combination with the {{key|Space}} navigation}}
{{clr}}
{{clr}}


'''3D Camera''' 视图中向上移动,并查看你刚才创建的地板。
Move up in the '''3D Camera''' viewport and look downward at the floor that you've just created.


[[File:P2_hammer_texture_browse.jpg|thumb|right|200px|caption|'''Texture'''面板上的'''Browse'''按钮。]]
[[File:P2_hammer_texture_browse.jpg|thumb|right|200px|caption|The '''Browse''' button on the '''Texture''' bar.]]


你会看到地板的贴图是默认的。 改变贴图的方法是,点击在 '''Texture''' 面板的 '''Browse'''按钮。
You'll notice there's a default texture on your floor. You'll probably want to change it. To change the current texture, click on the '''Browse''' button on the '''Texture''' Box.


会打开 '''Texture Browser''' 窗口。{{clr}}
This will bring up the '''Texture Browser''' window.{{clr}}


[[File:l4d_hammer_texture_dev.jpg|thumb|right|200px|caption|一般的灰色开发者纹理。]]
[[File:l4d_hammer_texture_dev.jpg|thumb|right|200px|caption|The generic gray developer texture.]]


在底部的 '''Filter''' 栏,可以按照名字来过滤贴图。在这个教程中,输入 <code>"dev_measure"</code>(包含下划线)。就会有一堆“开发者”贴图,来辅助创建东西。
In the '''Filter''' field at the bottom of the browse, you can filter the textures shown based on name. For this tutorial, type in the word <code>"dev_measure"</code> (with the underscore) into the field. This will bring up a listing of "developer" textures that will make it easier to create something quickly.


选择 <code>dev/dev_measuregeneric01b</code> 并双击。
Now, find the texture called <code>dev/dev_measuregeneric01b</code> and '''double-click''' on it.
{{clr}}
{{clr}}




[[File:l4d_hammer_texture_apply.jpg|thumb|right|400px|caption|将当前纹理应用到选定的brush上。]]
[[File:l4d_hammer_texture_apply.jpg|thumb|right|400px|caption|Applying the current texture to the selected brush.]]


这应该返回编辑器的4个视图,并将通用的开发人员纹理作为当前的纹理放在'''Texture'''面板中。
This should bring back the 4 viewports of the editor and place the generic developer texture as the current one in the '''Texture''' bar.


选择地板brush,如果它还没有被选中,通过在相机视窗点击它。 它应该变红。
Select the floor brush, if it isn't already selected, by clicking on it in the Camera viewport. It should turn red.


选择brush后, 点击'''Tool'''面板上的[[File:Hammer_ApplyCurrentTexture.png]] '''Apply current texture''' 图标将当前纹理应用于选区。 灰色开发者纹理应该出现在地板上,如图所示。
After the brush is selected, click on the [[File: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.
{{clr}}
{{clr}}


== 创建墙壁和天花板 ==
== Creating the walls and ceiling ==


现在让我们来看看如何创建墙壁和天花板。最简单的方法是'''复制'''地板brush。
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.


=== 复制 ===
=== Duplicating ===


你也可以选择一个现有的brush并复制它来创建它们。
You can also select an existing brush and duplicate it to create them.


{{Note|要复制,你需要设置'''Arrow keys nudge selected object/vertex'''选项,如果你在之前的教程中没有这样做。你可以在'''Tools > Options > 2D Tab'''下找到它。}}
{{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'''.}}


[[File:l4d_hammer_brush_04.jpg|right|thumb|300px|caption|复制brush来创造一个房间。]]
[[File:l4d_hammer_brush_04.jpg|right|thumb|300px|caption|Duplicating brushes to make a room.]]


复制:
To duplicate:
# 选择您创建的地板brush。
# Select the floor brush that you've created.
# 将光标移到'''Side''' 视图.
# Move your cursor over the '''Side''' viewport.
# 按住{{key|Shift}}键,并按{{key|}}键创建一个副本,并向上移动一个网格单元。
# Hold the {{key|Shift}} key down and press the {{key|Up_arrow}} key to create a duplicate and move it up 1 grid unit.


这将在现有地板的顶部创建与地板完全相同的brush。
This will create a brush exactly like the floor on top of the existing floor.


现在,您可以更改此新brush的大小和尺寸,以创建一堵墙,抓住brush上的角柄并将其拖动到所需的大小。 让我们将墙高128单位,厚16单位。
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.


{{提示|要移动创建的brush,请使用箭头键或简单地在brush中心内单击并拖动以将其拖动到其他位置。}}
{{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.}}


现在再将墙壁重复3次以勾勒地板轮廓。{{clr}}
Now duplicate the wall 3 more times to outline the floor.{{clr}}


[[File:l4d_hammer_brush_05.jpg|right|thumb|300px|caption|复制地板以创建天花板。]]
[[File:l4d_hammer_brush_05.jpg|right|thumb|300px|caption|Duplicating the floor to create a ceiling.]]
再将地板brush复制一遍,然后将其抬起成为天花板。
Duplicate the floor brush 1 more time and raise it to become the ceiling.


{{提示|在游戏中开始运行时,保持关卡整洁非常重要。 最好不要使用重叠的brush(彼此相交的brush)。 这可能会导致游戏中发生“z-fighting”,在这种情况下,多个表面会相互争夺显示。}}{{clr}}
{{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.}}{{clr}}


== 删除笔刷 ==
== Deleting brushes ==
要删除一个brush, '''Selection Tool''' [[File:hammer_select.png|28px]] 选中它并按下 {{key|Delete}} .
To delete a brush, select it with the '''Selection Tool''' [[File:hammer_select.png|28px]] and press the {{key|Delete}} key.


== 多选 ==
== Multiple selection ==
[[File:l4d_hammer_brush_06.jpg|right|thumb|300px|caption|将通用的橙色开发者纹理应用到墙壁上。]]
[[File:l4d_hammer_brush_06.jpg|right|thumb|300px|caption|Applying the generic orange developer texture to the walls.]]


您会注意到,在“Camera”视口中,如果您在房间内导航,由于所有的墙壁,地板和天花板都具有相同的纹理,因此很难分辨发生了什么。 接下来,我们将墙壁更改为其他纹理。
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.


通过按住{{key|Ctrl}}键,你可以在“Camera”视口中每次单击一个来选择所有墙。 您还必须使用{{key|SPACE}}键与鼠标左键来控制摄像头旋转,以便可以看到并选择每个墙。
You can select all of the walls by holding down the {{key|Ctrl}} key and clicking on them one at a time in the Camera viewport. You will have to use the {{key|SPACE}} camera controls to rotate the camera around so you can select each wall.


选中所有墙后,单击“Current texture”栏中的“Browse”按钮。 这次,选择当前纹理旁边的橙色纹理,标签为<code>dev/dev_measuregeneric01</code>。双击将其选中,浏览窗口会自动关闭。
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 <code>dev/dev_measuregeneric01</code>. Double-click it to select it and close the browser window.


使用 '''Tool''' 栏中的 [[File:Hammer_ApplyCurrentTexture.png]] 工具给墙壁应用橙色纹理。{{clr}}
Use the [[File:Hammer_ApplyCurrentTexture.png]] tool on the '''Tool''' Bar to apply the orange texture to the walls.{{clr}}


== 文件保存 ==
== Saving the file ==


想要保存文件, 你可以用快捷键{{key|Ctrl}}+{{key|S}}或者在'''File'''菜单栏里找到'''Save'''
To save a level, you can use {{key|Ctrl}}+{{key|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.


在本教材中将文件命名为"<code>tutorial01</code>"并将其保存到mapsrc目录中,默认位于
For this tutorial, name the map "<code>tutorial01</code>" and save it into the mapsrc directory, located by default at:
  C:\Program Files\Steam\steamapps\common\portal 2\sdk_content\maps\
  C:\Program Files\Steam\steamapps\common\portal\sdk_content\maps\


路径可能和默认给出的略有不同,具体取决于Steam安装位置。
Your directory may be slightly different, depending upon where you have installed Steam.


== 示例地图 ==
When naming your file, dont give it too long a name. Maps with names of excessive length will not load in-game.


当你保存地图时,你也许注意到<code>maps</code>路径下的其他文件。 Portal 2创作工具附带了一些示例地图来帮助。
== Placing entities ==


{| {{standard-table}}
[[File:P2_hammer_entity01b.jpg|thumb|left|300px|caption|Selecting the entity.]]
! Directory !! Contents
[[File:P2_hammer_entity01.jpg|thumb|right|300px|caption|Placing an info_player_start.]]
|-
| <code>maps\mp_coop_doors</code> || 简单的合作地图。
|-
| <code>maps\mp_coop_paint_red_racer</code> || 带有推进凝胶的合作地图。
|-
| <code>maps\sp_a2_column_blocker</code> || 带有强光桥和一些其他的东西的单人地图。
|-
| <code>maps\sp_a2_trust_fling</code> || 有空中信仰板的单人地图
|-
| <code>maps\sp_a3_speed_ramp</code> || 含推进凝胶单人地图。
|-
| <code>maps\sp_a4_laser_catapult</code> || 带旋涡、激光和空中信仰板的单人地图。
|-
| <code>maps\zoo_mechanics</code> || 包含《传送门2》中大部分游戏机制的地图。
|}


== 放置实体 ==
Next we'll place an entity in our level:
# Select the [[File:Hammer entity.png]] '''Entity Tool''' on the '''Tool''' Bar.
# Once the '''Entity Tool''' is enabled, the '''Entity''' selection list on the '''Object''' bar becomes active.
# Keep the '''Categories''' entry as '''Entities'''.
# Click the arrow on the '''Objects''' drop down list and select <code>info_player_start</code>.
# Now, navigate in the Camera viewport to the middle of the inside of the room.
# left-click on the floor to place the entity.
# Do the same with <code>weapon_portalgun</code> and try to place it in a position so the <code>info_player_start</code> is touching it.
<br />
This will place an <code>info_player_start</code> entity in the middle of the room. You will also receive a Portal Gun when you spawn.{{clr}}


[[File:P2_hammer_entity01b.jpg|thumb|left|300px|caption|选择实体。]]
=== Placing a light ===
[[File:P2_hammer_entity01.jpg|thumb|right|300px|caption|放置一个info_player_start。]]


接下来,我们该在地图里放第一个实体了:
Now we'll place a source of illumination in the map:
# 在'''工具栏'''里按下 [[File:Hammer entity.png]] '''实体工具'''
# Select the '''Entity Tool''' again
# 启用'''实体工具'''后, '''对象栏'''上的实体选择列表将变为活动状态。(看左图)
# Select <code>light</code> from the '''Objects''' drop down list on the '''Object''' bar.
# 保持'''Categories'''那一栏是'''Entities'''。(看左图)
# This time, place the light on the ceiling (above the player's head).
# 单击'''Objects'''的下拉列表并选择<code>info_player_start</code>。(一般Hammer默认就是这实体, 若不是自己找)
# Go back into selection mode by clicking on the [[File:Hammer select.png]] Selection tool in the '''Tool''' Bar or by pressing the {{key|Esc}} key.
# 现在, 在3D视口中来到房间内部的中间。
# 左键单击地面以放置实体


这样, 一个<code>info_player_start</code>实体就出现在房间中央了。{{clr}}
[[File:l4d_hammer_entity_02.jpg|thumb|left|500px|caption|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 {{key|Alt}}+{{key|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.{{clr}}
# 再次选择 '''Entity Tool'''
# 在对象栏的'''Objects'''的下拉列表里面找到<code>light</code>(点光源实体)。
# 现在将光源放到天花板下边 (高于玩家头顶)。
# 在'''工具栏'''点击[[File:Hammer select.png]]选择工具回到选择模式或者按下{{key|Esc}}键。
{{Note|如果放置位置距离天花板过于近, 或以后放置灯模型时距离太近会导致出现亮光斑或模型太亮等问题, 若出现此情况可以稍微将光放下面一点。(译者注)}}
[[File:l4d_hammer_entity_02.jpg|thumb|left|500px|caption|灯光的属性。]]


接下来我们要在灯上动一些设置了。 通过在3D视口双击它或先选中(左键单击)并按下{{key|Alt}}+{{key|Enter}}来查看灯的属性。 其实是打开'''对象属性对话框'''(或直接叫它'''属性面板''')。
[[File:l4d_hammer_entity_03.jpg|thumb|right|300px|caption|Picking a color for a light.]]


'''属性面板'''中, 你可以改变实体的各种属性。 比如你可以更改灯的'''Brightness'''(用来控制光的颜色和强度)。 点击'''Keyvalues'''下面的'''Brightness'''那行, 然后你可以看见右侧菜单上的一组数字, 默认是 255 255 255 200。 前三个数字表示RGB值( R红 G绿 B蓝 ), 最后一个数字表示光的强度。
Simply click on the color you want the light to be and click '''OK'''.


单击"选择颜色"按钮来选择颜色, 比直接输入数字更方便直观。{{clr}}
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.


[[File:l4d_hammer_entity_03.jpg|thumb|right|300px|caption|Picking a color for a light.]]
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.{{clr}}


找到你最想要的灯光颜色, 然后点击"OK"。
=== Placing a prop_static ===
[[File:l4d_hammer_entity_05.jpg|thumb|right|500px|caption|The Object Properties for a prop_static entity.]]


这时你会回到光源的'''属性面板'''。 如果选择了"Brightness"那一行, 你应该可以看到右侧菜单你对亮度所做的任何更改。
Entities also consist of props like furniture, decoration, and complex parts of architecture. There are a variety of different kinds of props. <code>Prop_static</code> entities are props that are static – they don't move, animate, turn on or turn off. There are also <code>prop_dynamic</code> 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.


单击“Apply”按钮设置对实体的更改,然后单击窗口右上角的"X"关闭对话框。(有时候按{{key|Enter}}比Apply方便些){{clr}}
To place a prop:
# Select on the '''Entity Tool''' again.
# Go to the '''Object''' bar and change the '''Objects''' field to <code>prop_static</code>.
# Point to the floor in front of the <code>info_player_start</code> and left-click to place a prop_static. You will see a red cube that represents the <code>prop_static</code> before a model is attached to it.
# Go back into selection mode by clicking on the [[File:Hammer select.png]] Selection tool in the '''Tool''' Bar or by pressing the {{key|Esc}} key.
# Double-click on the red cube to open the properties.
# Double-click on the '''World Model''' field to open the '''Model Browser'''.


{{Note|有很些开发者不会用此方法去放置想要的实体, 选中实体工具后直接放置, 再在属性面板改class等有时会更简便, 根据情况使用不同方法。(译者注)}}
{{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.}}{{clr}}


=== 放置一个 prop_static ===
=== Selecting the model ===
[[File:l4d_hammer_entity_05.jpg|thumb|right|500px|caption|prop_static实体的属性。]]


实体当然还包括家具、装饰和建筑复杂部分等道具, 且有各种不同类型的道具。 <code>Prop_static</code>实体是静态的道具 – 它们不可以移动、加入动画、打开或关闭。 它的"反义实体"<code>prop_dynamic</code>实体可以移动、设置动画、激活或关闭。 而<code>prop_physics</code>实体可以使玩家像在现实世界中一样与他们互动并表现出物理特性。
# In the '''Filter''' field at the bottom of the dialog box, type in "<code>cake</code>". This will show all the models that have the word "cake" in their name.
# Scroll down to the one named:
#: "<code>props\cake\cake.mdl</code>".
# 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.
# Click the Apply button to set your changes to the entity.
# Close the '''Properties''' box.


放置一个道具:
You will see the cake that you just placed in the room in the viewports in the editor.{{clr}}
# 再一次选择'''实体工具'''。
# 去'''对象栏'''并改变'''Objects'''成<code>prop_static</code>。
# 指向Francis模型前面的地板,然后左键单击以放置prop_static。 你将看到一个红色立方体, 意为没上模型前的<code>prop_static</code>。(Francis是求生之路角色之一, 是玩家出生点实体hammer显示模型,也许是官方直接复制求生之路教程忘记改了, 不用管,传送门2是你的小绿人。另外, 如果prop_static没上模型, 实体在游戏里不可见; 模型错误会显示传送门2特有的蓝ERROR)
# 还是在'''工具栏'''点击[[File:Hammer select.png]]选择工具或者按下{{key|Esc}}键。
# 双击红色方块打开'''属性面板'''或选中后按下{{key|Alt}}+{{key|Enter}}。
# 双击 '''World Model'''以打开'''模型浏览器'''.


{{warning|首次加载"模型浏览器"窗口时,可能需要一段时间才能加载所有模型。它可能不会看起来像在所给的图像, 而是异常的白色等, 此时重启模型浏览器。如果你找不到你要找的模型,给它一分钟的时间来完成加载。(原板Hammer特色)}}{{clr}}
== Moving entities ==


=== 选择模型: ===
You can move entities like our cake 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.  
[[File:P2_hammer_entity06.jpg|thumb|right|500px|caption|在模型浏览器中选择凝胶滴落器模型。]]


# 在模型浏览器底部的'''Filter'''(筛选器)中写"<code>paint</code>", 这样就只显示名称中有"paint"一词的所有模型。
{{clr}}
# 向下滚动找到一个模型:
#: "<code>props_underground\underground_paintdropper.mdl</code>".
#: 如果没有出意外, 它应该长得和所示图像一样。
# 单击'''OK'''选择这个模型并关闭模型浏览器, 然后返回'''属性面板'''对话框。 你现在应该可以在“World Model”中看到模型名称。
# 单击“Apply”按钮以设置对实体的更改。
# 关闭'''属性面板'''。
 
你可以在编辑器中的任何视口中看到刚才放置在房间中的凝胶滴落器。{{clr}}


== 移动实体 ==
== Rotating entities ==
 
你可以像搬家一样移动像凝胶滴落器这样的实体。
在选定实体的边界框内单击并拖动,用鼠标移动它,或将鼠标放在任何视口上,然后使用键盘上的箭头键移动它们。在Hammer++中支持3D视口实体的移动。


To rotate an object , you simply select the object you wish to rotate using the '''Selection Tool''' [[File:hammer_select.png|28px]], 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.
{{clr}}
{{clr}}


== 旋转实体 ==
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.


要旋转对象,只需使用'''选择工具''' [[File:hammer_select.png|28px]]并单击对象一次。 你理论上可以看到物体的四个角变成了空心圆(○), 之后将鼠标悬停在任何2D视口中的圆上,然后按住并拖动以旋转对象。
Left-click and drag in a counter-clockwise motion to rotate the paintdropper so that it can drop paint from the ceiliing. {{clr}}
{{clr}}


使用鼠标滚轮放大'''前'''视口, 在凝胶滴落器模型的边界框内单击一次, 使其四个角都用圆圈突出显示。
== Running your level in the game ==


左键单击并逆时针拖动, 以旋转凝胶滴落器, 使其可以从天花板上滴落凝胶。 {{clr}}
[[File:hammer_setmapparam.png|thumb|right|300px|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.


[[File:hammer_setmapparam.png|thumb|right|300px|更改'''Run Map'''的设置, 然后点击'''OK'''。]]
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 {{key|F9}} key.
* The '''Run Map''' dialog will open.
* This dialog is used to set some basic compile parameters.
*# Make sure that '''Normal''' is set under the '''Run BSP''', '''Run VIS''', and '''Run RAD''' settings.
*# Under '''Additional game parameters:''', make sure these settings are present, and type them in if not:
*#: <code>-toconsole -dev -console +sv_lan 1</code>
*# You may wish to check "Wait for keypress" so that you can see any error messages that occur.
*# Now click the '''OK''' button to start the map compile process.


编译地图时, 它会从刚保存的原始 {{L|VMF|.VMF}} 文件转换为游戏引擎使用的 {{L|BSP (Source)|.BSP}} 格式。经过几何处理, 并使用多个编译程序预先计算出适当的照明和阴影。
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.


* 打开'''File'''菜单,并点击'''Run Map...''', 或按下{{key|F9}}键。
{{note|If you wish to compile with [[HDR|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.}}
* '''Run Map'''对话框打开。
{{clr}}
* 这个对话框是用于设置一些基本的编译参数。
*# 确保'''Run BSP''','''Run VIS'''和'''Run RAD'''设置选择了'''normal'''。
*# 确保'''Additional game parameters:'''下面有以下几个设置, 若没有请打入:
*#: <code>-toconsole -dev -console +sv_lan 1</code>(在传送门2中有点过于繁琐, 你甚至不需要这些设置,-toconsole和-console是打开控制台,-dev是开发者模式, +sv_lan 1是仅局域网, 译者注)
*# 现在点击'''OK'''按钮开始编译地图。


{{Warning|如果你的地图{{L|Leak|泄露}}或有其他错误, 可能导致编译失败。(译者注)}}
Your level in the game should load up after compiling. It may take a minute or two.


'''编译进程窗口'''将显示编译的进度。编译完成后, 您正在映射的游戏将自动启动, 并将您的地图加载到引擎中。
Next time you compile, you may wish to check the "Don't run the game after compiling" checkbox. Otherwise, it will complain that only one instance of the game can run at once. Instead of exiting and relaunching the game (slow!), you can simply recompile the map (F9) and then type <code>map myMapFileName</code> in the developer console to reload the map.


{{note|如果你想带有{{L|HDR|High Dynamic Range(HDR)}}光照, 只需要勾上'''HDR'''复选框。 编译地图的时间将是原来的两倍, 这是完全正常的。}}
[[File:P2_hammer_tutorial01.jpg|thumb|right|400px|caption|Running the level in the game.]]
编译完成后, 游戏中应该会加载地图, 可能需要一两分钟。
{{clr}}
[[File:P2_hammer_tutorial01.jpg|thumb|right|400px|caption|在游戏中运行的地图。]]


== 开发者控制台 ==
== The Developer console ==


为Portal 2做关卡有时需要''{{L|Developer Console|开发者控制台}}''命令辅助。 控制台可以用来做一些特别的事情, 比如生成立方体和炮塔来测试你的关卡。
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.


[[File:P2_hammer_console01.jpg|thumb|400px|caption|激活开发者控制台。(英文界面)]]
[[File:P2_hammer_console01.jpg|thumb|400px|caption|Enabling the developer console.]]


如果你还没有启用控制台, 请按照以下步骤做:
If you haven't already, make sure the console is enabled in the game:
# 在游戏中按下{{key|Esc}}
# Press the {{key|Esc}} key in the game.
# 点击'''选项''', 之后按'''键盘/鼠标'''
# Click on '''Options''', then '''Keyboard'''.
# 点击'''允许使用开发者控制台'''并选择"'''已启用'''"。(游戏内的翻译还是差点味)
# Click on the '''Advanced''' and check "'''Enable developer console'''".
# 点击'''完成'''按钮。
# Click on the '''OK''' Button.
# 点击'''返回'''


使用开发者控制台:
Using the developer console:


# {{key|`}}打开控制台(波浪键)
# Bring down your developer console {{key|`}} (tilde).
# 输入控制台命令,然后按{{key|Enter}}键。
# Type any console command and press the {{key|Enter}} key.
# 再次按{{key|`}}隐藏控制台。
# Hide the console again with {{key|`}}.


{{clr}}
{{clr}}


== 穿墙模式 ==
== Noclip mode ==


记一个非常有用的控制台命令''noclip''。这是一种可以让你在水平面上飞行的模式, 而不会被水平面上的任何东西阻挡。跳关这块, 非常好用。(此命令需要sv_cheats 1)
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.


进入<code>noclip</code>模式:
To enter <code>noclip</code> mode:
* 按下{{key|`}}打开控制台。
* Press {{key|`}} to enter the console.
* 在控制台里输入<code>sv_cheats 1</code>并按下{{key|Enter}}。(进入游戏只需要输入一次, 目的在于设置服务器可以开启作弊, 若noclip失效再输入此命令尝试)
* Type <code>noclip</code> in the console and press {{key|Enter}}.
* 在控制台里输入<code>noclip</code>并按下{{key|Enter}}
* Fly around the level.
* 在关卡附近飞飞。
* Type <code>noclip</code> again to leave noclip and walk around the level normally.
* 再次输入<code>noclip</code>退出穿墙模式并正常地在关卡里走走。
* You can toggle noclip with the press of a button with the bind console command. For example, <code>bind mouse3 noclip</code> for the middle mouse button.
* 您可以通过按下绑定控制台命令中的按钮来切换穿墙。 比如按下鼠标中间切换穿墙指令<code>bind mouse3 noclip</code>


== 一些有用的控制台命令 ==
== Some useful console commands ==


有很多可以使用的控制台指令,下面是一些例子:
There are lots of [[Console Command List|console commands]] available. Here is a very small sampling:


; sv_cheats 1
; sv_cheats 1
: 打开作弊,这样就可以使用很多平时不能使用的指令。
: Turns on cheats. Necessary for many console commands.


; map <nowiki><地图名></nowiki>
; map <nowiki><name of map></nowiki>
: 打开一个地图。
: Loads a map or reloads the level you're in.


; changelevel <nowiki><地图名></nowiki>
; changelevel <nowiki><name of map></nowiki>
: 在已有的会话(通俗点说就是不关闭服务器)的情况下更换地图。
: Loads a map while continuing the session.


; god 1
; god
: 开启/关闭无敌。
: Toggle the god mode. The player is invulnerable.


; noclip
; noclip
: 开启/关闭穿墙飞行。(需要sv_cheats 1)
: Allows you to fly through the world.


{{navbar2|Zh/Level Design Introduction (Portal 2)/Getting Started|入门|Zh/Level Design Introduction (Portal 2)|传送门2关卡设计介绍|Zh/Level Design Introduction (Portal 2)/Gotchas|常见问题}}
[[Category:Portal]]
{{ACategory|Portal 2 Level Design}}

Latest revision as of 17:43, 18 July 2025

English (en)中文 (zh)Translate (Translate)
Note.pngNote:This article was modified by WoShiGeNiCheng(我是个昵称-hello) by modifying the article Portal 2 to create the first level, and it will be removed if it is infringing(probably not).
Note.pngNote:Since not many people learn Hammer from the first generation of Portal, it is recommended to start from the second generation.Your First Level(Portal 2)

A brush is a simple 3D shape created with Hammer's Block tool. Brushes are used to created the majority of large surfaces in your level, such as ceilings and floors. We will now create a simple room using brushes.

Creating a floor brush

Drawing a brush.
  1. From the Tool bar on the left, select the Hammer block.png Block Tool.
  2. Now, left-click and drag in the Top 2D view in a movement that is Right and Downward as shown below.
  3. You should see a dotted outline of a rectangle or square as you drag.
  4. Create a square 512x512 units and let go of the left-mouse button.
  5. Press Enter on your keyboard to create this brush that you've just drawn.

To go back to selection mode, click on the Hammer select.png Selection tool icon on the Tool bar or press the Esc key.

In selection mode, with the brush selected, you can change the size of the brush by left-clicking on any of the boxes that appear on the borders of the brush and dragging them out or in.

Let's decrease the thickness of the brush (which we'll be using as a floor) from the default 64 units to 16. To do this, we need to change the size of the grid.

The grid

A grid is displayed in all the 2D views. By default, all objects snap to the grid. Although you can turn this off, it is considered good practice to leave it on because it prevents leaks and other errors in your map.

The default grid size is 64 units, which means that each line is 64 units apart. The current size of the grid is displayed in the status bar at the bottom of the Hammer window.

  • Clicking the Smaller Grid icon Hammer SmallerGrid.png will make the grid half as big, for finer adjustments. You can also decrease the grid size with the [ key
  • Clicking the Larger Grid icon Hammer LargerGrid.png will make the grid twice as big, for larger adjustments. You can also increase the grid size with the ] key.

To bring the grid size down to 16 units, press the [ key twice. Look at the Status bar at the bottom right of the Hammer window and make sure it reads Grid: 16. If it doesn't, press [ or ] until is does.

Resize the floor

Lowering the height of a brush in the Side viewport.

Now the grid should be small enough.

Switch to the bottom right viewport. It should be labeled Side when you mouse over it. Drag the top border of the brush down so that it's 16 units thick.

Moving brushes

Click & drag in any 2D view to move a brush.

You can move brushes around once they're created. Select the Selection Tool Hammer select.png and mouse over the brush in one of the 2D views, staying clear of the corner handles. The pointer will change into four arrows pointing in all four directions FourArrows.png, indicating the option to move the object.

Click and drag the brush to move the brush in any of the 2D views. Upon release, the brush will be moved to that position.

Configuring the options in Hammer.

You can also move objects with the arrow (cursor) keys. To do that, we'll need to change a setting in the Hammer options to allow the arrow keys to be used:

  1. Go to Tools menu and pick Options to bring up the Configure Hammer dialog box.
  2. Click on the 2D Views tab.
  3. There are other settings here as well, but for now, we just need to check the box marked Arrow keys nudge selected object/vertex.
  4. Press OK to confirm the change and close the settings.

Now let's move the floor brush down 16 units by placing the mouse cursor over the Side viewport and pressing the Down_arrow once.

Moving a brush down in the Side viewport.
Note.pngNote:You'll need your ground plane on the same level as the origin line so that the nav file included will work.

Navigating in the 2D viewports

  • Use can use the scrollbars to pan the view.
  • For a faster method, hold down the Space bar and left-click and drag to pan.
  • Use the Mouse Wheel to zoom in and out.

Texturing

To see textures in the 3D Camera viewport, right-click on the camera text in the 3D Camera viewport and select 3D Textured.

Selecting the 3D Textured mode in the Camera viewport.

Navigating in the 3D Camera viewport

Moving around in 3D is a bit different from the 2D viewports:

  • Hold down the Space and left-click and drag to rotate the camera.
  • Hold down the Space and right-click and drag to move up/down and left/right.
  • Hold down the Space and both right and left-click and drag to move forward and backward.
  • You can also use W, A, S, and D to move forward, backward, strafe left and strafe right respectively.
  • The Z key toggles on and off "mouse look" mode. Move your mouse cursor over the 3D Camera viewport and press the Z key. You can now move your mouse around as if mouse look was on in the game.
Note.pngNote:The W A S D keys can be used in combination with the Space navigation

Move up in the 3D Camera viewport and look downward at the floor that you've just created.

The Browse button on the Texture bar.

You'll notice there's a default texture on your floor. You'll probably want to change it. To change the current texture, click on the Browse button on the Texture Box.

This will bring up the Texture Browser window.

The generic gray developer texture.

In the Filter field at the bottom of the browse, you can filter the textures shown based on name. For this tutorial, type in the word "dev_measure" (with the underscore) into the field. This will bring up a listing of "developer" textures that will make it easier to create something quickly.

Now, find the texture called dev/dev_measuregeneric01b and double-click on it.


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.

Creating the walls and ceiling

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.

Duplicating

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

Note.pngNote: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.pngTip: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.pngTip: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.

Deleting brushes

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

Multiple selection

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.

Saving the file

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\sdk_content\maps\

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

When naming your file, dont give it too long a name. Maps with names of excessive length will not load in-game.

Placing entities

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.
  7. Do the same with weapon_portalgun and try to place it in a position so the info_player_start is touching it.


This will place an info_player_start entity in the middle of the room. You will also receive a Portal Gun when you spawn.

Placing a 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.

Placing a 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 info_player_start 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.pngWarning: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

  1. In the Filter field at the bottom of the dialog box, type in "cake". This will show all the models that have the word "cake" in their name.
  2. Scroll down to the one named:
    "props\cake\cake.mdl".
  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 cake that you just placed in the room in the viewports in the editor.

Moving entities

You can move entities like our cake 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.

Rotating entities

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.

Running your level in the game

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. You may wish to check "Wait for keypress" so that you can see any error messages that occur.
    4. 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.pngNote: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.

Next time you compile, you may wish to check the "Don't run the game after compiling" checkbox. Otherwise, it will complain that only one instance of the game can run at once. Instead of exiting and relaunching the game (slow!), you can simply recompile the map (F9) and then type map myMapFileName in the developer console to reload the map.

Running the level in the game.

The Developer console

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.
  3. Click on the Advanced and check "Enable developer console".
  4. Click on the OK Button.

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

Noclip mode

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.

Some useful console commands

There are lots of console commands available. Here is a very small sampling:

sv_cheats 1
Turns on cheats. Necessary for many console commands.
map <name of map>
Loads a map or reloads the level you're in.
changelevel <name of map>
Loads a map while continuing the session.
god
Toggle the god mode. The player is invulnerable.
noclip
Allows you to fly through the world.