Auto-sync: 2026-04-26 12:02
This commit is contained in:
37
wiki/concepts/ServerAuthority.md
Normal file
37
wiki/concepts/ServerAuthority.md
Normal file
@@ -0,0 +1,37 @@
|
||||
---
|
||||
title: "Server Authority"
|
||||
type: concept
|
||||
tags: [networking, multiplayer, security]
|
||||
sources: [unity-multiplayer-engineer]
|
||||
last_updated: 2026-04-26
|
||||
---
|
||||
|
||||
## Aliases
|
||||
- Server Authority Model
|
||||
- Server-Authoritative Architecture
|
||||
|
||||
## Definition
|
||||
服务器权威模型是一种多人游戏网络架构范式,其中**服务器拥有所有游戏状态的最终真相**,包括玩家位置、生命值、分数、物品所有权等。客户端仅发送输入请求,服务器模拟并广播权威状态给所有客户端。
|
||||
|
||||
## Key Principles
|
||||
- 客户端**永远不直接发送位置数据**——只发送原始输入(方向键、鼠标点击等)
|
||||
- 服务器执行所有游戏逻辑模拟,客户端显示服务器返回的结果
|
||||
- **"永远不要信任来自客户端未经服务器验证的值"**
|
||||
- 客户端预测移动后必须与服务器状态调和校正
|
||||
|
||||
## Implementation in Unity (NGO)
|
||||
```csharp
|
||||
// 服务器权威位置(只有服务器可写)
|
||||
private NetworkVariable<Vector3> _serverPosition = new NetworkVariable<Vector3>(
|
||||
readPerm: NetworkVariableReadPermission.Everyone,
|
||||
writePerm: NetworkVariableWritePermission.Server);
|
||||
```
|
||||
|
||||
## Related Concepts
|
||||
- [[ClientPrediction]]: 客户端预测在服务器权威框架下的实现
|
||||
- [[LagCompensation]]: 延迟补偿依赖服务器权威
|
||||
- [[AntiCheatArchitecture]]: 服务器权威是反作弊的基础
|
||||
|
||||
## Related Entities
|
||||
- [[UnityMultiplayerEngineer]]: 实现服务器权威的专家角色
|
||||
- [[UnrealMultiplayerArchitect]]: 虚幻引擎中的对应角色
|
||||
Reference in New Issue
Block a user