Skilllibrary multiplayer-netcode
Implements multiplayer networking with client-server authority, state synchronization, lag compensation, and prediction across Unity Netcode, UE5 Replication, and Godot MultiplayerAPI. Use when building networked gameplay, syncing game state, adding prediction/rollback, or designing lobby systems. Do not use for single-player networking or REST API work.
install
source · Clone the upstream repo
git clone https://github.com/merceralex397-collab/skilllibrary
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/merceralex397-collab/skilllibrary "$T" && mkdir -p ~/.claude/skills && cp -r "$T/13-game-engines-and-creative-tech/multiplayer-netcode" ~/.claude/skills/merceralex397-collab-skilllibrary-multiplayer-netcode && rm -rf "$T"
manifest:
13-game-engines-and-creative-tech/multiplayer-netcode/SKILL.mdsource content
Purpose
Provides architecture patterns and engine-specific APIs for multiplayer game networking: authority models, state replication, lag compensation, prediction, and matchmaking.
When to use this skill
- Implementing client-server or peer-to-peer multiplayer architecture
- Synchronizing game state (positions, health, inventory) across networked players
- Adding client-side prediction, server reconciliation, or rollback netcode
- Building lobby, matchmaking, or session management systems
- Optimizing bandwidth with delta compression, priority-based sync, or tick rate tuning
Do not use this skill when
- The networking task is a REST API or web service — use backend/API skills instead
- The task is about single-player game logic with no network component
- Input handling has no multiplayer aspect — prefer
input-mapping-controller
Operating procedure
- Choose an authority model. Client-server authoritative is the default for competitive games — the server owns game state and validates all inputs. Peer-to-peer suits co-op or small lobbies but is vulnerable to cheating. Relay servers add NAT traversal without full authority.
- Implement state synchronization.
- Unity Netcode for GameObjects: Extend
. UseNetworkBehaviour
for synced state. Mark server logic withNetworkVariable<T>
and client callbacks with[ServerRpc]
. Spawn networked objects via[ClientRpc]
.NetworkObject.Spawn() - UE5 Replication: Mark properties with
and implementUPROPERTY(Replicated)
. UseGetLifetimeReplicatedProps()
for client-to-server calls,UFUNCTION(Server, Reliable)
for server-to-client. SetUFUNCTION(Client, Reliable)
on Actors.bReplicates = true - Godot MultiplayerAPI: Set
on the scene tree. Usemultiplayer_peer
or@rpc("authority")
annotations. Check@rpc("any_peer")
for authority. Usemultiplayer.is_server()
for ownership.set_multiplayer_authority()
- Unity Netcode for GameObjects: Extend
- Add lag compensation. Implement client-side prediction: simulate movement locally using the same logic the server runs. On server correction, snap or interpolate back. For fighting/action games, consider rollback netcode (re-simulate N frames on correction).
- Interpolate remote entities. Buffer received snapshots and interpolate between them (typically render one snapshot behind). Use snapshot interpolation at 20–60Hz tick rates to smooth visual positions.
- Optimize bandwidth. Send delta-compressed state (only changed fields). Prioritize sync by relevance (nearby entities update more often). Target packet sizes under 1200 bytes to avoid fragmentation. Typical tick rates: 20Hz (casual), 30Hz (standard), 60Hz+ (competitive shooters).
- Validate on the server. Never trust client-reported positions, damage, or inventory changes. Server checks movement speed limits, line-of-sight for hits, cooldown timers, and rate limits inputs to prevent spam.
- Implement lobby and matchmaking. Use platform SDKs (Steam Networking, EOS, PlayFab) or custom relay. Handle host migration if the host disconnects in P2P. Separate lobby state from gameplay state.
- Choose transport. UDP with a custom reliability layer (or libraries like ENet, LiteNetLib) for gameplay. WebRTC for browser-based multiplayer. TCP only for non-latency-sensitive data (chat, leaderboards).
Decision rules
- Default to client-server authoritative — it prevents the most common cheats.
- Replicate only what each client needs (relevancy/interest management).
- Prediction is essential for player-controlled movement; optional for other entities.
- Use reliable RPCs for critical events (damage, death); unreliable for frequent state updates (position).
- Keep tick rate as low as acceptable — every tick costs bandwidth × player count.
- Test with simulated latency (100–300ms) and packet loss (1–5%) during development.
Output requirements
— authority model, topology diagram, tick rate, transport protocolArchitecture
— which state is synced, ownership, update frequencyReplication Schema
— what is predicted client-side, reconciliation strategyPrediction/Compensation
— latency simulation test results, bandwidth per-player measurementValidation
References
- Unity Netcode for GameObjects: https://docs-multiplayer.unity3d.com/netcode/current/about/
- UE5 Networking: https://docs.unrealengine.com/5.3/en-US/networking-and-multiplayer-in-unreal-engine/
- Godot High-Level Multiplayer: https://docs.godotengine.org/en/stable/tutorials/networking/high_level_multiplayer.html
- Gabriel Gambetta netcode articles: https://www.gabrielgambetta.com/client-server-game-architecture.html
Related skills
— input prediction and network input handlinginput-mapping-controller
— bandwidth and tick rate optimizationperformance-profiling-games
— persisting multiplayer match state and replayssave-load-state
— designing systems that work under network constraintsgame-design-systems
Failure handling
- If the target engine is unknown, clarify before writing netcode — APIs differ significantly.
- If latency exceeds 200ms in testing, increase interpolation buffer before adding more prediction complexity.
- If bandwidth is too high, audit replication: reduce tick rate, add delta compression, or tighten relevancy.
- If desync occurs, add server-side state checksums and reconciliation logging before debugging individual systems.