关卡设计介绍/你的第一个关卡(Portal 2)

From Valve Developer Community
Jump to: navigation, search
English (en)Deutsch (de)Español (es)Magyar (hu)한국어 (ko)Русский (ru)中文 (zh)Translate (Translate)

brush(en)(刷子)是在Hammer中用Block工具创建的3D物体。Brush用来创建天花板和地板之类大块的表面的。我们将使用brush来创建一个房间。

用brush创建地板

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

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

在选择模式中,选中刚才的那个brush,左键单击边缘的小方块可以改变brush的大小。

现在我们来调整这个brush的厚度(为了用来做地板),从64单位调整到16。但首先要调整grid(网格)的大小。

关于网格

grid出现在每个2D视图。默认情况下,任何物体都会对齐到网格(grid)。虽然你可以关闭对齐到网格,但是还是留着比较好,以防止在地图中出现泄漏(leak)之类的错误。

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

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

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

调整地板的大小

在侧视图中降低brush的高度。

现在网格应该足够小了。

看右下方的视图。鼠标移上去的时候,应该显示Side标签。拖动brush的上边缘,令它的厚度为16单位。

移动brush

在2D视图的点击并拖动来移动brush。

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

在2D视图中点击并拖动brush。一旦释放,brush就移动到新的位置了。

Hammer的选项

也可以使用方向键移动物体。但首先要设置一下Hammer的选项,方法如下:

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

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

在侧视图中向下移动brush
Note.png注意:您需要将地平面与原点线放在同一水平面上,以便包含的导航文件可以正常工作。

在2D视图中导航

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

材质

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

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

在3D Camera视图中导航

在3D中移动和2D视图中有所不同:

  • 按住 Space 键,并拖动鼠标左键旋转镜头。
  • 按住 Space 键,并拖动鼠标右键,用来上下左右移动镜头。
  • 按住 Space 键,并同时按住鼠标左右键进行拖动,来前后移动镜头。
  • 按住 Space 键时,也可以用 W, A, S, 和 D 键,来移动镜头。
  • Z 键,用来开关 "mouse look" 模式。切换到3D Camera视图,并按下 Z 键。就可以像在游戏中那样用鼠标控制镜头了。
Note.png注意:W A S D键可以与Space导航结合使用

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

Texture面板上的Browse按钮。

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

会打开 Texture Browser 窗口。

一般的灰色开发者纹理。

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

选择 dev/dev_measuregeneric01b 并双击。


将当前纹理应用到选定的brush上。

这应该返回编辑器的4个视图,并将通用的开发人员纹理作为当前的纹理放在Texture面板中。

选择地板brush,如果它还没有被选中,通过在相机视窗点击它。 它应该变红。

选择brush后, 点击Tool面板上的Hammer ApplyCurrentTexture.png Apply current texture 图标将当前纹理应用于选区。 灰色开发者纹理应该出现在地板上,如图所示。

创建墙壁和天花板

现在让我们来看看如何创建墙壁和天花板。最简单的方法是复制地板brush。

复制

你也可以选择一个现有的brush并复制它来创建它们。

Note.png注意:要复制,你需要设置Arrow keys nudge selected object/vertex选项,如果你在之前的教程中没有这样做。你可以在Tools > Options > 2D Tab下找到它。
复制brush来创造一个房间。

复制:

  1. 选择您创建的地板brush。
  2. 将光标移到Side 视图.
  3. 按住 Shift键,并按键创建一个副本,并向上移动一个网格单元。

这将在现有地板的顶部创建与地板完全相同的brush。

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

Tip.png提示:要移动创建的brush,请使用箭头键或简单地在brush中心内单击并拖动以将其拖动到其他位置。

现在再将墙壁重复3次以勾勒地板轮廓。

复制地板以创建天花板。

再将地板brush复制一遍,然后将其抬起成为天花板。

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

删除笔刷

要删除一个brush, 用 Selection Tool Hammer select.png 选中它并按下 Delete 键.

多选

将通用的橙色开发者纹理应用到墙壁上。

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

通过按住Ctrl键,你可以在“Camera”视口中每次单击一个来选择所有墙。 您还必须使用SPACE键与鼠标左键来控制摄像头旋转,以便可以看到并选择每个墙。

选中所有墙后,单击“Current texture”栏中的“Browse”按钮。 这次,选择当前纹理旁边的橙色纹理,标签为dev/dev_measuregeneric01。双击将其选中,浏览窗口会自动关闭。

使用 Tool 栏中的 Hammer ApplyCurrentTexture.png 工具给墙壁应用橙色纹理。

文件保存

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 简单的合作地图。
maps\mp_coop_paint_red_racer 带有推进凝胶的合作地图。
maps\sp_a2_column_blocker 带有强光桥和一些其他的东西的单人地图。
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.

放置一个光源

现在我们将在地图上放置一个光源:

  1. 再次选择 Entity Tool
  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.png警告: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:
    "props_underground\underground_paintdropper.mdl".
    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.

移动实体

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.png注意:If you wish to compile with High Dynamic Range(en) 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(en) 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
开启/关闭无敌。
noclip
开启/关闭穿墙飞行。