用户手册 > 多玩家和联机 > 联机简介
联机简介
从联机的角度看,有两种类型的的用户:
脚本高级 API
Unity 的联机功能提供了『高级』脚本 API(称为 HLAPI)。高级 API 涵盖了多人游戏所需的大部分常用命令,你不需要关系那些『低级』API 的实现细节。高级 API 允许你:
- 使用『网络管理器』控制游戏的联机状态。
- 操作『客户端』游戏,主机也是一个玩家终端。
- 使用多功能序列化器序列化数据。
- 发送和接收网络信息。
- 从客户端向服务端发送网络命令。
- 从服务端向客户端执行远程过程调用(RPC)。
- 从服务端向客户端发送网络事件。
整合引擎和编辑器
Unity’s networking is integrated into the engine and the editor, allowing you to work with components and visual aids to build your multiplayer game. It provides:
A NetworkIdentity component for networked objects.
A NetworkBehaviour for networked scripts.
Configurable automatic synchronization of object transforms.
Automatic synchronization of script variables.
Support for placing networked objects in Unity scenes.
Network components
Internet Services
Unity offers Internet Services to support your game throughout production and release, which includes:
Matchmaking service
Create matches and advertise matches.
List available matches and join matches.
Relay server
Game-play over internet with no dedicated server.
Routing of messages for participants of matches.
NetworkTransport real-time transport layer
We include a Real-Time Transport Layer that offers:
Optimized UDP based protocol.
Multi-channel design to avoid head-of-line blocking issues
Support for a variety of levels of Quality of Service (QoS) per channel.
Flexible network topology that supports peer-to-peer or client-server architectures.
Sample Projects
You can also dig into our multiplayer sample projects to see how these features are used together. The following sample projects can be found within this Unity Forum post:
Multiplayer 2D Tanks example game
Multiplayer Invaders game with Matchmaking
Multiplayer 2D space shooter with Matchmaking
Minimal Multiplayer project