Files
nexus/wiki/concepts/Replication-Graph.md
2026-04-26 12:02:53 +08:00

55 lines
2.2 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: "Replication Graph"
type: concept
tags: [unreal-engine, networking, multiplayer, ue5]
sources: [unreal-multiplayer-architect]
last_updated: 2026-04-26
---
## Definition
Replication Graph 是 UE5 的空间分区复制优化系统,用空间网格分区替代默认的扁平相关性模型。通过只向相关客户端复制区域内的 Actor显著降低带宽消耗。核心机制`UReplicationGraphNode_GridSpatialization2D`(开放世界空间网格)和自定义 `UReplicationGraphNode`(休眠 Actor 优化)。
## Core Mechanisms
- **空间网格分区**:基于 2D 空间网格,将世界划分为网格单元,每个单元仅复制给附近玩家
- **休眠 Actor 优化**NPC 等休眠 Actor 不在任何玩家附近时,以极低频率复制
- **动态 relevancy**:根据客户端视角动态决定 Actor 的相关性
- `UReplicationGraphNode_GridSpatialization2D`:开放世界空间分区节点
- `UReplicationGraphNode`:可自定义的复制图节点基类
## Implementation
```cpp
// 启用 Replication Graph 插件
// DefaultEngine.ini
[/Script/OnlineSubsystemUtils.IpNetDriver]
ReplicationGraphClassName=ReplicationGraph.UReplicationGraph
// 自定义休眠节点
UCLASS()
class UMyDormancyNode : public UReplicationGraphNode
{
// 重写 DetermineWrites 会话逻辑
};
```
## Key Benefits
- 开放世界多人游戏中带宽降低 40%+
- 仅复制视野内 Actor减少不必要的网络流量
- 可自定义节点类型适配特殊需求
## Network Profiling Commands
- `net.RepGraph.PrintAllNodes` — 打印所有复制图节点信息
- Unreal Insights — 性能分析工具,测量复制图对带宽的影响
## Connection to Other Concepts
- [[Actor Replication]] — Replication Graph 是 Actor 复制的空间优化层
- [[Server-Authoritative Model]] — 服务器权威通过复制图高效同步状态到客户端
- [[Network Prediction]] — 预测系统依赖高效的复制同步
## Relationship to Agent
[[UnrealMultiplayerArchitect]] 使用 Replication Graph 作为生产级多人游戏的带宽优化方案,性能基准:\"Bandwidth per player < 15KB/s at maximum player count\"。
## Aliases
- UE5 Replication Graph
- Spatial Replication
- Grid Spatialization