# 从 Nakama 部署

多人游戏玩家期望从独立游戏到大型三A级作品在任何地方都能获得相同的高质量在线体验，无论他们在纽约还是雅加达。

对于游戏开发者来说，这一标准要求 **可扩展的后端服务与其游戏服务器托管同步工作** 以确保无缝的最终用户体验，能够即时帮助用户上线并在具有实时性能的游戏服务器上进行游戏。

为流行游戏引擎或自定义引擎部署专用游戏服务器，完全集成 Nakama 的开源玩家数据和游戏服务，提供便捷的交钥匙解决方案。

{% hint style="success" %}
这是与独立合作伙伴共同维护的经过验证的解决方案—— [Heroic Labs](https://heroiclabs.com).
{% endhint %}

## 🚀 快速开始

Nakama（由 Heroic Labs 提供）与 Edgegap 之间的集成旨在简化部署可扩展、低延迟游戏服务器的流程。以下是其工作原理概述：

1. **使用 Nakama 的匹配与玩家管理**: [Nakama 处理用户账号、匹配和玩家数据管理](https://heroiclabs.com/docs/nakama/getting-started/index.html)，使用稳健的架构来支持玩家之间的实时交互。一旦 Nakama 确认应开始匹配，它就会在 Edgegap 上触发一个游戏实例。
2. **Edgegap 的动态服务器部署**：Edgegap 接收来自 Nakama 的请求并 [在最优位置部署服务器实例](/zh/learn/bian-pai/deployments.md) ，基于实时数据，例如玩家的位置和设备信息。这确保游戏服务器靠近玩家，最小化延迟并创造流畅的游戏体验。
3. **实时通信**：该集成允许 Nakama 的游戏后端与 Edgegap 的部署网络之间进行无缝通信。Nakama 提供匹配、大厅系统和一般元游戏玩法功能，而 Edgegap 确保核心游戏循环（在无头游戏引擎例如 Unity 上运行）无论玩家身处何处都尽可能高效地运行。Edgegap 与 Nakama 之间的连接意味着玩家可以更好地与彼此配对，以及与运行在 Edgegap 上的现有或新比赛进行匹配。
4. **可扩展性与负载管理**：Edgegap 的系统会根据玩家需求动态扩展或缩减资源，而 Nakama 可扩展以容纳数百万用户，即使在高峰时段也是如此。此组合允许开发者在流量高峰期间保持一致的性能，而不会过度承诺资源。

<figure><img src="/files/11723e84e98c3d7d7be666e01573da1731b91ff0" alt=""><figcaption></figcaption></figure>

## ⚡ 集成

☑️ **安装并配置 Nakama**: [首先将 Nakama 设置为您游戏的后端](https://heroiclabs.com/docs/nakama/getting-started/install/)。将其配置为处理用户账户、匹配、多人会话以及其他游戏逻辑：

* 以 [Heroic 云](https://heroiclabs.com/heroic-cloud/), [创建一个新的构建器](https://heroiclabs.com/docs/heroic-cloud/concepts/builders/) 使用 [nakama-edgegap 插件仓库](https://github.com/edgegap/nakama-edgegap),
* 以 [自托管 Nakama](/zh/learn/advanced-features/managed-clusters.md#nakama-by-heroic-labs), [按照插件使用说明在本地构建您的镜像](https://github.com/edgegap/nakama-edgegap?tab=readme-ov-file#usage)

☑️ **注册 Edgegap**: [注册 Edgegap 网络平台](https://app.edgegap.com/auth/register) 以便上传您的专用服务器镜像并检索下一步所需的 API 密钥和密令。Edgegap 在开发期间提供免费试用托管，其无约束且具有竞争力的按分钟付费定价确保工作室仅在玩家活跃时付费，无需前期成本或固定月费：

* [服务器入门（Unity）](/zh/unity.md),
* [服务器入门（Unreal 引擎）](/zh/unreal-engine.md).

☑️ **将 Nakama 连接到 Edgegap**：使用 Nakama 的 FleetManager 实现连接 Edgegap 的部署服务。请遵循 [详细指南以配置两项服务](https://github.com/edgegap/nakama-edgegap?tab=readme-ov-file#nakama-setup).

🙌 恭喜您将 Nakama 集成到 Edgegap 部署中！

{% hint style="success" %}
**自动化游戏服务器集成** 使用 [Edgegap Server Nakama Unity 插件](https://github.com/edgegap/edgegap-server-nakama-plugin-unity).
{% endhint %}

## 🚨 故障排除


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.edgegap.com/zh/docs/tools-and-integrations/cong-nakama-bu-shu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
