参考

UE4的多人在线游戏采用的是client-server模型。意味着有一个单独的server负责游戏状态的裁判,同时所有其他remote终端都维持一份本地相对server的近似。

Server是多人里重要的一部分,它做出所有重要的决定:

Starting a Server

基本命令行(这些命令use the editor,因而不依赖cooked data):

Type

Command

Listen Server

UE4Editor.exe ProjectName MapName?Listen -game

Dedicated Server

UE4Editor.exe ProjectName MapName -server -game -log

Client

UE4Editor.exe ProjectName ServerIP -game

Server Gameplay Flow

The server is in charge of driving the flow of gameplay. It is the server's job to notify clients that it is time to travel to a new map, when gameplay starts and ends, along with actor replication updates, etc.

主要的游戏框架超出本文的范畴,这里只是简单提及一些:
Gameplay state and flow are generally driven through the GameMode Actor. Only the server contains a valid copy of this Actor (the client doesn't contain a copy at all). To communicate this state to the client, there is a GameState Actor, that will shadow important state of the GameMode Actor. This GameState Actor is marked to be replicated to each client. Clients will contain an approximate copy of this GameState Actor, and can use this Actor as a reference to know the general state of the game.

上面的话解释一下就是:UE4游戏进展基本上是靠GameMode Actor来驱动的。并且只有Server上有该Actor,其他client端没有。client端要想获知游戏进展,需要依靠GameState Actor,在Server上有一个Authoritative GameState Actor,它屏蔽了GameMode Actor的一些重要内部细节,并将除此之外的关于game state的信息replicates到remote proxies,client端可根据这些proxies获知游戏状态。