Files
nexus/wiki/concepts/NetworkPrediction.md
2026-05-03 05:42:12 +08:00

48 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Network Prediction"
type: concept
tags: ["unreal-engine", "networking", "latency-compensation"]
sources: ["unreal-multiplayer-architect", "unreal-multiplayer-architect"]
last_updated: 2026-04-30
---
## Aliases
- 网络预测
- 客户端预测
- Client-side Prediction
## 定义
网络预测是客户端在等待服务器确认时本地预测游戏结果的技术,使玩家感觉不到网络延迟,提升游戏响应体验。
## 工作原理
1. 玩家输入 → 客户端立即应用预测结果
2. 客户端同时发送输入到服务器
3. 服务器执行相同逻辑
4. 服务器将结果复制回客户端
5. 客户端比较预测与实际结果
6. 如有差异进行协调Reconciliation
## UE5 Network Prediction Plugin
UE5 提供的官方预测框架,支持物理驱动或复杂移动的回滚:
- `FNetworkPredictionStateBase` — 预测状态基类
- 每秒预测状态数 = 网络频率
- 支持移动、能力、交互等多系统
## 预测与权威的关系
```
预测(客户端) 权威(服务器)
↓ ↓
立即响应 ←─────── 确认/回滚
↓ ↓
显示结果 ←─────── 复制结果
```
## 性能指标
- 200ms 延迟下每玩家每 30 秒去同步事件应 < 1 次
- 过多去同步 = 预测逻辑与服务器不一致
## 相关概念
- [[Server-Authoritative Model]] — 预测的基础是服务器权威
- [[GAS (Gameplay Ability System)]] — GAS 内置 Prediction Key 支持
- [[Actor Replication]] — 预测结果通过复制验证