Auto-sync: 2026-04-26 12:02
This commit is contained in:
36
wiki/concepts/LagCompensation.md
Normal file
36
wiki/concepts/LagCompensation.md
Normal file
@@ -0,0 +1,36 @@
|
||||
---
|
||||
title: "Lag Compensation"
|
||||
type: concept
|
||||
tags: [networking, multiplayer, latency]
|
||||
sources: [unity-multiplayer-engineer]
|
||||
last_updated: 2026-04-26
|
||||
---
|
||||
|
||||
## Aliases
|
||||
- Server-Side Lag Compensation
|
||||
- 延迟补偿
|
||||
|
||||
## Definition
|
||||
延迟补偿是一种在服务器权威模型下**考虑网络延迟影响**的技术。当服务器处理客户端的射击/命中请求时,需要将客户端的请求时间「回溯」到网络延迟对应的时间点,以提供公平的命中判定。
|
||||
|
||||
## Problem It Solves
|
||||
在没有延迟补偿的情况下:
|
||||
- 客户端 A 看到命中了客户端 B
|
||||
- 但由于网络延迟,B 已经移动到了新位置
|
||||
- 结果:A 的命中被服务器拒绝,但 A 看到的是命中效果 → 体验不一致
|
||||
|
||||
## Standard Approach
|
||||
1. 客户端发送带有**时间戳**的输入/射击请求
|
||||
2. 服务器根据网络延迟计算**回溯时间**
|
||||
3. 服务器将目标玩家「回放」到回溯时间点的位置
|
||||
4. 在该位置进行命中判定
|
||||
5. 结果同步给所有客户端
|
||||
|
||||
## Related Concepts
|
||||
- [[ServerAuthority]]: 延迟补偿依赖服务器权威
|
||||
- [[ClientPrediction]]: 两者结合提供流畅且公平的游戏体验
|
||||
- [[AntiCheatArchitecture]]: 延迟补偿同时是反作弊的重要手段
|
||||
|
||||
## Related Entities
|
||||
- [[UnityMultiplayerEngineer]]: 实现延迟补偿的专家
|
||||
- [[UnrealMultiplayerArchitect]]: 虚幻引擎中的对应实现
|
||||
Reference in New Issue
Block a user