在编辑器中进行联网游戏

在编辑器中游戏 支持多个环境,因此,您可以测试联网游戏。编辑器会在已装入的 UE4 实例中生成多个环境,这可缩短迭代时间,并 允许您调试每个环境的 蓝图

设置联网测试

关卡编辑器工具栏蓝图编辑器工具栏 中的 游戏位置(Play In) 下拉菜单中,您可以设置在开始 在编辑器中游戏 会话时要创建多少个用户端环境。 另外,您可以指定是否运行专用的服务器。

networking_settings.png

用户端数目(Number of Clients) 字段允许您指定要测试的玩家总数。如果设置为 1,并且未选中 运行专用服务器(Run Dedicated Server)复选框, 那么 在编辑器中游戏 会话将允许您测试非联网的单机游戏。

此下拉菜单中提供的另一个基本联网选项是 运行专用服务器(Run Dedicated Server)复选框。如果选中此项,那么将启动“专用服务器”环境,但是没有专用服务器的显示或本地玩家。 使用专用服务器意味着没有用户端作为侦听服务器来运行。专用服务器使您能够查找局限于专用服务器的错误,例如依赖于本地玩家的代码。对于功能依赖于服务器和用户端的 蓝图, 简单的测试配置是将 玩家数(Number of Players)设置为 1,并将 运行专用服务器(Run Dedicated Server)设置为 true。只有一个窗口用于测试游戏,但其具备连接到专用服务器的用户端的完整功能。

设置这些选项后,请选择您偏爱的 在编辑器中游戏 模式开始测试游戏。如果您有多个用户端环境,并且为 在编辑器中游戏 会话选择 视口(Viewport)显示类型,那么将在视口中显示一个用户端环境,而所有其他用户端环境都将显示在新窗口中。以下示例图像显示使用 4 个玩家和专用服务器进行测试。

单击可查看标准大小的图片:

您可以使用 Shift+TabControl+Tab 在用户端窗口之间循环切换焦点。

高级设置

用户端环境数目以及是否使用专用服务器也可以在 “关卡编辑器 - 游戏位置设置”(Level Editor - Play In Settings)窗口 中设置。在此处, 您还可以指定要发送给预览会话的任何命令行选项。您还可以通过取消选中 使用单个进程(Use Single Process)复选框来恢复先前的联网 在编辑器中游戏 行为。

设置 说明
玩家数目(Number of Players)

The editor and listen server count as players, a dedicated server will not. Clients make up the remainder.

服务器游戏选项(Server Game Options)

Additional options that will be passed to the server as URL parameters, in the format ?bIsLanMatch=1?listen - any additional command line switches should be passed in the Command Line Arguments field below.

运行专用服务器(Run Dedicated Server)

If checked, a separate dedicated server will be launched. Otherwise the first player will act as a listen server that all other players connect to.

将第一个游戏手柄连接到第二个用户端(Route 1st Gamepad to 2nd Client)

When running multiple player windows in a single process, this option determines how the game pad input gets routed. If unchecked (default) then the 1st game pad is attached to the 1st window, 2nd to the 2nd window, and so on.

            If it is checked, the 1st game pad goes the 2nd window. The 1st window can then be controlled by keyboard/mouse, which is convenient if two people are testing on the same computer.
使用单个进程(Use Single Process)

Spawn multiple player windows in a single instance of [API:UE4] . This will load much faster, but has potential to have more issues.

调试蓝图

现在,在多环境场景中运行时,蓝图编辑器 将提供一个额外的下拉菜单,用于选择要调试的环境:

bp_debugger_multiplayer_pie.png

环境列表将对 Actor 列表中的 Actor 进行过滤。例如,如果选择“全部环境”,那么您将在另一个下拉列表中看到每个环境中的 Actor。如果选择其他环境中的某个环境,那么您将只看到该环境实例中的 Actor。

这也会影响断点。例如,如果将调试环境设置为“用户端 1”,那么断点只会在“用户端 1”环境中的 Actor 上触发。

通过查看窗口标题,您可以看到预览窗口的用户端数目。例如,在以上联网游戏图像中,有一个标题为 ShooterGame 游戏预览用户端 1((64 位/PCD3D_SM5))(ShooterGame Game Preview Client 1 (64bit/PCD3D_SM5))的窗口。

如果选择“所有环境”(All Worlds),那么任何环境都可以触发断点。那些断点触发时,蓝图编辑器将显示所调试的环境:

bp_graph_multiplayer_pie.png