如何将对局配对整合到您的大逃杀游戏中
-> 本文基于對局配對文档。如果您遇到问题或差异,请确保参考原始指南,因为它们的更新频率更高。
以下示例将帮助您测试核心對局配對玩家流程,具体包括:
在共享托管集群上创建对局配对实例,
在您的对局配对配置中定义规则和设置,
最后,使用我们的玩家票和API测试玩家流程和管理。
有五个步骤将我们的对局配对功能集成到您的游戏中:
第一步是创建一个账户并使用我们的BR游戏示例。Voilà,您(技术上)完成了一半!您只需将对局配对功能整合到您的游戏中(见第5步)。
现在,您不应盲目跟随在网上找到的JSON示例,因此强烈建议将上述规则适应于您的游戏。步骤2(“探索配置”)是我们的“如何阅读”,它详细介绍了每个对局配对规则功能(“探索配置”)。
步骤3(“审查实例细节”)涵盖了您的个人、具体对局配对,以确保其与您的游戏设计部署并合作。
正如名称所示,步骤4(“4.测试票据API”)全部是关于测试来自玩家的對局配對请求是否被对局配对接收到,称为票据。
步骤5(“将对局配对集成到您的游戏中”)强调如何在引擎的项目中集成对局配对。
如果您遇到故障排除问题,我们的深入学习中心提供了其他故障排除提示。
1. 设置免费套餐
注册您的免费Edgegap账户,然后导航到 对局配对仪表板页面。
从那里,首先点击 创建对局配对 然后输入:
为您的对局配对命名 – 仅供您自己参考,例如 quickstart-dev,
然后,上传以下简单示例作为BR游戏的JSON配置:
{
"version": "1.0.0",
"max_deployment_retry_count": 3,
"ticket_expiration_period": "5m",
"ticket_removal_period": "1m",
"profiles": {
"casual-example": {
"application": {
"name": "my-game-server=>CHANGE-THIS-NAME-HERE",
"version": "2024.01.30-16.23.00-UTC=>CHANGE-THIS-HERE "
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 1
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"10": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"30": {
"beacons": {
"difference": 50
}
},
"60": {
"league_rank": {
"max_difference": 2
}
},
"180": {
"beacons": {
"difference": 100,
"max_latency": 500
}
}
}
}
},
"competitive-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"60": {
"beacons": {
"difference": 50
}
},
"180": {
"beacons": {
"max_latency": 250
}
}
}
}
},
"challenger-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"180": {
"beacons": {
"difference": 50
}
},
"240": {
"beacons": {
"max_latency": 250
}
}
}
}
}
}
}{
"version": "1.0.0",
"max_deployment_retry_count": 3,
"ticket_expiration_period": "5m",
"ticket_removal_period": "1m",
"profiles": {
"casual-example": {
"application": {
"name": "my-game-server=>CHANGE-THIS-NAME-HERE",
"version": "2024.01.30-16.23.00-UTC=>CHANGE-THIS-HERE "
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 1
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"10": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"30": {
"beacons": {
"difference": 50
}
},
"60": {
"league_rank": {
"max_difference": 2
}
},
"180": {
"beacons": {
"difference": 100,
"max_latency": 500
}
}
}
}
},
"competitive-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"60": {
"beacons": {
"difference": 50
}
},
"180": {
"beacons": {
"max_latency": 250
}
}
}
}
},
"challenger-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"180": {
"beacons": {
"difference": 50
}
},
"240": {
"beacons": {
"max_latency": 250
}
}
}
}
}
}
}{
"version": "1.0.0",
"max_deployment_retry_count": 3,
"ticket_expiration_period": "5m",
"ticket_removal_period": "1m",
"profiles": {
"casual-example": {
"application": {
"name": "my-game-server=>CHANGE-THIS-NAME-HERE",
"version": "2024.01.30-16.23.00-UTC=>CHANGE-THIS-HERE "
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 1
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"10": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"30": {
"beacons": {
"difference": 50
}
},
"60": {
"league_rank": {
"max_difference": 2
}
},
"180": {
"beacons": {
"difference": 100,
"max_latency": 500
}
}
}
}
},
"competitive-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"60": {
"beacons": {
"difference": 50
}
},
"180": {
"beacons": {
"max_latency": 250
}
}
}
}
},
"challenger-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"180": {
"beacons": {
"difference": 50
}
},
"240": {
"beacons": {
"max_latency": 250
}
}
}
}
}
}
}{
"version": "1.0.0",
"max_deployment_retry_count": 3,
"ticket_expiration_period": "5m",
"ticket_removal_period": "1m",
"profiles": {
"casual-example": {
"application": {
"name": "my-game-server=>CHANGE-THIS-NAME-HERE",
"version": "2024.01.30-16.23.00-UTC=>CHANGE-THIS-HERE "
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 1
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"10": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"30": {
"beacons": {
"difference": 50
}
},
"60": {
"league_rank": {
"max_difference": 2
}
},
"180": {
"beacons": {
"difference": 100,
"max_latency": 500
}
}
}
}
},
"competitive-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"60": {
"beacons": {
"difference": 50
}
},
"180": {
"beacons": {
"max_latency": 250
}
}
}
}
},
"challenger-example": {
"application": {
"name": "my-game-server",
"version": "2024.01.30-16.23.00-UTC"
},
"rules": {
"initial": {
"match_size": {
"type": "player_count",
"attributes": {
"team_count": 2,
"team_size": 5
}
},
"beacons": {
"type": "latencies",
"attributes": {
"difference": 25,
"max_latency": 100
}
},
"league_rank": {
"type": "number_difference",
"attributes": {
"max_difference": 0
}
},
"selected_maps": {
"type": "intersection",
"attributes": {
"overlap": 1
}
},
"selected_beacons": {
"type": "intersection",
"attributes": {
"overlap": 1
}
}
},
"expansions": {
"30": {
"beacons": {
"difference": 40,
"max_latency": 150
}
},
"180": {
"beacons": {
"difference": 50
}
},
"240": {
"beacons": {
"max_latency": 250
}
}
}
}
}
}
}(友情提醒请确保更改应用 名称 和 版本 以匹配您的 应用和版本!)
如果未出现验证错误,请点击 创建并启动 并等待过程完成。这将导致一个新的免费集群启动,带有您的简单示例对局配对。
您现在可以继续下一步。
2. 探索配置
独特的BR游戏规则
专门针对大逃杀游戏,您可以为游戏模式定义多个 对局配对配置文件 以适应特定的规则和设置:
在较随意的游戏中限制两位玩家等级差异,
在排位赛中仅允许排名相同的对手进行对战,
允许玩家提供他们的地图偏好,并选择适合所有人的地图,
添加 中心选择UI 以限制对手到指定的 Ping信标,
限制 对局配对延迟 到最大阈值以防止匹配远处的玩家,
将 对局配对延迟 限制在最大差异内以最大化ping公平性,
使用不同的应用版本分配更多CPU或内存以容纳更多玩家,
作为团队加入 用于预制大厅或在不超过团队规模的情况下填充团队。
从理想条件开始, 扩展限制 确保快速匹配:
逐渐放宽延迟限制以找到更多玩家,
慢慢增加允许的等级差以找到更多玩家,
增加扩展之间的时间以给最高等级玩家(挑战者)多一些可用性,因为玩家较少。
创建票据时使用更高的等级进行晋升赛,以匹配更强的对手。
定义 独立的作弊者配置文件 以确保标记的作弊者或收到大量管理报告的玩家不会对排名赛中合法玩家的体验产生负面影响。
语义版本控制
每个新版本使用 语义版本控制 通过解释格式 major.minor.patch清楚传达变化的影响:
major 版本包含重大更改,需要进行集成审查,
minor 版本包含实质性向后兼容的改进,
patch 版本包含错误修复和小的改进。
某些 部署可能导致错误。我们尝试通过在 max_deployment_retry_count 次尝试部署(无需客户确认)来解决此问题。
为了确保意外的客户端崩溃或被抛弃的票据不会持续存在并占用您的对局配对资源,票据将在 ticket_expiration_period 过期后取消,其状态会更改为 取消,并在 ticket_removal_period 后永久删除。
我们的对局配对逻辑核心是在 对局配对配置文件中配置的。每个配置文件是一个完全独立的对局配对队列,指向预定义CPU和内存(RAM)资源的应用版本。
初始规则集中的對局配對规则必须满足以便玩家被分组在一起,每个规则由三个属性定义:
您选择的名称,例如 - 匹配规模,
规则类型,也称为操作符,例如 - 玩家数量,
最后是操作符属性,例如 团队数量 或 团队规模。
玩家数量规则
这是一个特殊规则,定义需要多少玩家匹配才能开始分配:
团队数量 指的是团队的数量,可以用于合作或自由游戏模式,
团队规模 指的是 每个团队的玩家数量。
我们的简单示例展示了一个有2名玩家的合作游戏。
请注意,“玩家数量”规则需定义唯一并且只能在初始配置规则中定义一次。
延迟规则
使用此规则为所有玩家提供最低可能的ping值。一旦客户端测量并提交到所有可用信标的往返时间(ping),Gen2将仅考虑在特定 差异 范围内的匹配,测量对比 Ping信标。这为分裂您的玩家群体提供了一个“软”解决方案,能够与邻近地区进行匹配,尤其是提高边缘地区的匹配速度。使用 最大延迟来阻止与距离较远的玩家进行匹配。
您现在可以继续下一步。
我们的“信标”示例规则如上所示,使用 "差异": 50, "最大延迟": 200起初:
由于北京被排除(>200),其余在 | A-B | < 50范围内,爱丽丝和鲍勃将匹配:
爱丽丝 {蒙特利尔: 12.3, 纽瓦克: 45.6, 达拉斯: 59.9, 北京: 264.4}; 和
鲍勃 {蒙特利尔: 27.3, 纽瓦克: 32.4, 达拉斯: 23.1, 北京: 252.2}。
查理和戴夫将不匹配,因为达拉斯信标的 | C-D | > 50:
查理 {蒙特利尔: 5.7 纽瓦克: 44.2, 达拉斯: 59.5, 北京: 263.2}; 和
戴夫 {蒙特利尔: 57.8, 纽瓦克: 32.0, 达拉斯: 24.2, 北京: 272.3}。
请注意,“延迟规则”只能在初始配置规则中定义一次。
3.审查实例细节
在初始化后,在我们的仪表板中审查新对局配对的详情:

状态 指示服务健康状况,可能为在线,离线或错误。
标识符 帮助Edgegap员工快速查找对局配对以协助故障排除。
启动时间 有助于追踪最近的更新时间。
大小 对应于我们的其中一个定价等级。
API URL 将用于游戏客户端和游戏服务器与Gen2通信。
Swagger URL 是一个方便的我们提供的openAPI规范GUI,用于探索API架构。
认证令牌 是游戏客户端和游戏服务器用于身份验证的唯一秘密令牌。
使用API测试您的新对局配对,您将需要Swagger URL、API URL和认证令牌。
您现在可以继续下一步。
4. 测试票据API
首先,打开您的Swagger URL 以在swagger GUI中检查您的openAPI架构
点击“对局配对”标题下的/...swagger.json URL以打开原始JSON架构:

将此页面保存为您驱动器上的文件(CTRL/CMD+S)。
打开您的 Postman应用程序 并登录您的免费账号。
从上一步导入您的 swagger.json 文件:
保持Postman Collection选择,
选择查看导入设置并更改设置参数生成为示例。
确认导入,这将导致一个新的集合出现在左侧的集合列表中,名为对局配对。

查看更多操作,打开授权 选项卡并选择:
身份验证类型 - API密钥,
密钥 - “授权”
值 - 在这里插入您的 认证令牌,
添加到 - Header。
按(CTRL/CMD+S)或保存图标以 保存更改。Postman选项卡中的橙色点应消失。
在您的对局配对集合中,选择 票据 并 创建对局配对票据,打开一个新选项卡。
选择主体 选项卡以预览您的 玩家票据请求:
注意 玩家ip 设置为 null- 这将导致自动使用添加到您请求中的IP地址(请参阅 服务器到服务器集成 以获取替代方案),
配置文件 指的是您的 对局配对配置文件,
属性 包含对局配对规则的值,在此情况下为 延迟 规则,
规则 玩家数量 是唯一不需要在玩家票中添加任何属性的规则。
注意:请确保参考示例的Swagger的导入配置.
点击 发送并查看您的玩家票据请求的响应:
id 是您的唯一对局配对票证ID,保存此以稍后检查您的票证,
配置文件 确认选择对局配对配置文件,
组id 是每张票证发出的唯一组ID,单个玩家表示为一个组1,
请参阅 加入小组 以与您的朋友或团队进行对局配对,
玩家ip 是玩家的公开IP地址,无论使用哪种身份识别方法,
分配 设置为 null 以指示票证尚未匹配或分配到服务器,
创建于 提供有关何时为游戏UI使用创建玩家票的数据,
状态 指示票证的当前状态,所有票证均以搜索状态开始(请参阅对局配对过程的详细信息)。
通过再次点击 发送 创建第二张票据,以便我们的两个玩家匹配并启动服务器。
在您的对局配对集合中,选择 {票证Id} 并 读取对局配对票据。
输入上一步响应中的票证ID并点击 发送。

查看您玩家票证的更新分配:
状态首先更改为 找到匹配 ,同时保持 分配 设置为 null 以指示玩家已匹配并正在分配服务器,

再次点击 发送 检查您的票证,并查看您玩家票证的更新分配:
状态更改为 主机已分配 ,并具有包含已分配服务器详细信息的 分配。
在我们的仪表板中检查您的新部署:
请注意,每个部署都标有所有票证ID和配置文件以增加可追溯性。

尝试从您的游戏客户端连接到已分配的服务器。
一旦您验证您可以连接到您的部署并没有问题并完成测试,停止您的部署 以为下一个构建释放您账户中的容量。
您现在可以继续下一步。
5. 将对局配对整合到您的游戏中
Edgegap的对局配对集成:
与游戏客户端一起,管理 玩家票证,
与 游戏服务器,以:
处理玩家偏好通过其票据传递的,
可选择支持 回填 以在开始后添加或替换玩家。
在 游戏客户端中,我们建议在整个对局配对过程中向玩家提供票证状态更新,使用游戏中的UI,以便获得最佳玩家体验。详见:
在 游戏客户端中,确保您正在处理不可重试的错误:
HTTP 404 未找到 - 票证已被删除,
HTTP 500 内部服务器错误 - 临时服务中断。
在 游戏服务器中,处理玩家偏好和初始服务器上下文。无需API集成:
读取 注入的环境变量(Gen2) 以检索初始玩家的对局配对数据。
读取 注入的环境变量(应用版本) 以获取版本特定的参数、设置(玩家容量)和密钥。
读取 注入的环境变量(部署) 以获取部署信息,例如IP地址、位置或更多。
一旦玩家连接, 游戏服务器和游戏客户端 开始加载场景以执行同步步骤(例如选择和加载地图/场景/关卡)。我们推荐一个完善的3D场景,一个类似大厅的社交UI,或带有进度条的加载页面,以指示初始化正在进行。
一旦 游戏客户端 完全加载,玩家载入/前往主要游戏场景。
可选地, 游戏服务器 可以创建和管理 回填 和玩家容量(增加或替换离开的玩家)。
确保您的部署将被正确停止 使用 注入的删除URL,如果:
没有玩家加入匹配,
所有玩家已离开比赛,
比赛正确结束。
恭喜,您已完成Edgegap对局配对的整合!如需了解更多,请阅读我们学习中心的全部内容。