WECHAT

扫码添加微信

YoungFan 微信二维码
← 返回 UE5 笔记
前后端Gameplay时间线 封面
开发笔记已归档

前后端Gameplay时间线

多人游戏中,前后端各个Gameplay相关Actor创建时序

UE5Gameplay多人游戏

时序图

┌──────────────────────── SERVER ────────────────────────┐   ┌──────────────────────── CLIENT ────────────────────────┐
│ Engine Start                                           │   │ Engine Start                                             │
│                                                        │   │                                                          │
│ GameInstance                                           │   │ GameInstance                                             │
│  (唯一 / 进程级)                                        │   │  (唯一 / 进程级)                                          │
│                                                        │   │                                                          │
│ ───────────── Load Map ─────────────                   │   │ ───────────── Load Map ─────────────                    │
│ UWorld                                                 │   │ UWorld                                                   │
│ LevelScriptActor                                       │   │ LevelScriptActor                                         │
│                                                        │   │                                                          │
│ GameModeBase  (✔ Server Only)                         │   │ ❌ GameMode 不存在                                       │
│   ├─ InitGame                                          │   │                                                          │
│   ├─ InitGameState                                     │   │                                                          │
│                                                        │   │                                                          │
│ GameStateBase (创建 + Replicate)                       │◀──┼── Replicated GameState                                │
│                                                        │   │                                                          │
│ Level Actors (Placed)                                  │   │ Level Actors (Placed)                                    │
│                                                        │   │                                                          │
│ PlayerController (Server Authority)                    │◀──┼── PlayerController (Client Proxy)                     │
│   ├─ PlayerState                                       │◀──┼── PlayerState                                          │
│                                                        │   │                                                          │
│ Spawn Pawn                                             │◀──┼── Pawn (Replicated)                                    │
│   └─ Possess                                           │   │   └─ OnRep_Controller                                    │
│                                                        │   │                                                          │
│ ───────────── BeginPlay Phase ─────────────            │   │ ───────────── BeginPlay Phase ─────────────             │
│ LevelScriptActor::BeginPlay                            │   │                                                          │
│ GameMode::BeginPlay                                    │   │                                                          │
│ GameState::BeginPlay                                   │◀──┼── GameState::BeginPlay                                 │
│ PlayerController::BeginPlay                            │◀──┼── PlayerController::BeginPlay                          │
│ Pawn::BeginPlay                                        │◀──┼── Pawn::BeginPlay                                      │
│ Other Actors::BeginPlay                                │◀──┼── Other Actors::BeginPlay                               │
│                                                        │   │                                                          │
│ Tick / Gameplay Logic                                  │◀──┼── Tick / Gameplay Logic                                 │
└────────────────────────────────────────────────────────┘   └──────────────────────────────────────────────────────────┘

所属关系

服务器拥有所有Gameplay对象,但不包含HUD。

客户端拥有自己的HUD、自己的PlayerController、GameState和所有玩家的PlayerState、Pawn。

参考图

关卡蓝图 LevelScriptActor

关卡蓝图在关卡加载完成后创建,但不会立即调用BeginPlay。其创建时间早于GameMode但晚于GameInstance。 关卡蓝图同时存在于服务端和客户端,但它不是网络复制对象,逻辑各自本地执行。

Discussion

留言讨论

无需注册账号
正在加载留言区…

发表留言时,评论服务会记录必要的 IP 与 User-Agent 信息,用于安全审核和防止滥用。