协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
multiplayer-netcode【开发与工程】Engine-level multiplayer netcode engineering - transport protocols, replication, latency hiding (prediction/interpolation), lag compensation, rollback, and scalability for game engines.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Building netcode that is fast, fair, and stable requires decisions at the transport, protocol, simulation, and presentation layers. This skill gives the full architecture used by modern FPS/MOBA engines, independent of any specific engine — then shows how each engine (Unity/Unreal/Godot) maps onto it.
Client Server
Input sampler (fixed rate) -> Input validator
| (unreliable channel) Simulation (authoritative, fixed tick)
Local Prediction (client sim) Snapshot builder (delta vs ack)
Interpolation buffer Priority queue (interest management)
Reconciliation (rebase on snap) <- Unreliable snapshots (30-60Hz)
| Protocol | Native use | Web use |
|---|---|---|
| UDP | game state (fast) | not in browsers (use WebRTC) |
| TCP | reliable control, telemetry | -- |
| WebSocket | web game both | byte framing, reliable only |
| WebRTC | -- | unreliable + datachannel for web |
Rule: use an unreliable+reliable multiplexed channel on UDP (RakNet/uNet-like, custom). Web fallback: WebRTC datachannel or WebSocket with its own reliable/unreliable split.
struct ClientInput { uint32_t seq; float forward, right; bool jump, fire; };
Client::Frame() {
auto in = Input::sample(); // fixed rate (e.g., 60Hz)
pending_.push({ in, localTick_, state_ }); // store for reconciliation
Simulate(in); // LOCAL prediction
transport_.send(unreliable, in); // to server
}
Server::Tick(tick) {
processInputs(); // apply each client's input in arrival order
simulate(); // physics, AI, combat (fixed step)
buildSnapshot(); // delta against client acks
}
tick -> state.tick, positions, velocities, HP.void Client::OnSnapshot(const Snapshot& s) {
auto& predicted = history_[s.tick];
if (dist(predicted.pos, s.pos) > kTolerance) {
state_ = s.state; // rebase
for (auto& p : pendingAfter(tick)) // replay
Simulate(p.input);
}
}
serverTime - interpDelay -> smooth between two snapshots.t_client + hit params.t_client (using 100-250ms history).f(relevance) — high for your combat, low for ambient.RepProps/SyncVar patterns; update only when changed, throttle by frequency.| Feature | Unity (NGO) | Unreal | Godot (HLLAPI) |
|---|---|---|---|
| Main loop | NetworkManager tick | NetTick | SceneMultiplayer |
| RPC | [ServerRpc]/[ClientRpc] | UFUNCTION(Server) | rpc() |
| Sync | NetworkVariables | ReplicatedProps+conditions | MultiplayerSynchronizer |
| Prediction | custom (no built-in) | built-in move | manual |
| Interpolation | NetworkTransform (lerp) | built-in | MultiplayerSynchronizer |
| Rollback | custom | built-in (fighter support) | custom |
Old Unity MLAPI migrated to Netcode for GameObjects (2023.1+). Unreal has the strongest built-in for prediction. Godot's is minimal — you implement buffers yourself.
client tick monotonic and within window.skills/game/multiplayer-netcode/SKILL.mdskills/game/game-engine/ecs-pattern/references/ecs-netcode.mdskills/game/unity/SKILL.md (§9), skills/game/unreal/SKILL.md (§7), skills/game/godot/SKILL.md (§8)skills/game/game-development/physics-engine/SKILL.md