Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when synchronizing multiplayer state — MultiplayerSynchronizer, interpolation, prediction, and lag compensation
.claude/skills/jame581-multiplayer-sync/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-02 | ✗→✓ | ▲ Improved | 168% | 0% |
| case-04 | ✗→✓ | ▲ Improved | 19% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 44% | 0% |
| case-15 | ✓→✓ | = Same ✓ | 204% | 0% |
| case-01 | ✓→✓ | = Same ✓ | 139% | 0% |
All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, then C#.
> Related skills: multiplayer-basics for ENet setup, RPCs, and authority model, dedicated-server for headless export and deployment, physics-system for physics interpolation and RigidBody synchronization.
MultiplayerSynchronizer is Godot's built-in node for replicating properties across the network. Add it as a child of the node whose state you want to share.
MultiplayerSynchronizer node in the scene tree.position, velocity).0 means every physics frame.| Property | Description | |---|---| | replication_interval | Seconds between full sync updates. 0 = every physics frame | | delta_interval | Seconds between delta sync updates. 0 = disabled | | public_visibility | When true, updates go to all peers (default) | | visibility_filters | Array of Callables; each returns true if a peer should receive updates |
| Mode | How It Works | Best For | |---|---|---| | Full sync | Sends all configured properties every replication_interval | Simple objects, low property count | | Delta sync | Sends only properties that changed since last sync, every delta_interval | Objects with many properties that change infrequently |
Use both together: set replication_interval for periodic full state and delta_interval for frequent change-only bursts.
gdscript# Only send updates to peers within 500 units of this object. func _ready() -> void: $MultiplayerSynchronizer.add_visibility_filter(_is_peer_in_range) func _is_peer_in_range(peer_id: int) -> bool: var peer_player := _get_player_node(peer_id) if peer_player == null: return false return global_position.distance_to(peer_player.global_position) <= 500.0
csharp// Only send updates to peers within 500 units of this object. public override void _Ready() { var sync = GetNode<MultiplayerSynchronizer>("MultiplayerSynchronizer"); sync.AddVisibilityFilter(Callable.From<int>(IsPeerInRange)); } private bool IsPeerInRange(int peerId) { var peerPlayer = GetPlayerNode(peerId); if (peerPlayer is null) return false; return GlobalPosition.DistanceTo(peerPlayer.GlobalPosition) <= 500.0f; }
Sync the minimal state needed to reconstruct the visual on remote peers. Typical properties:
| Property | Type | Notes | |---|---|---| | position | Vector2 / Vector3 | Core transform — sync every frame or use interpolation | | velocity | Vector2 / Vector3 | Helps remote prediction stay ahead of position snaps | | health | int / float | Sync reliably on change; delta sync is ideal | | animation_state | String / int | Sync on change; use an enum int to save bandwidth | | is_crouching | bool | Low-change boolean; delta sync or RPC on change |
gdscript# synced_player.gd extends CharacterBody2D ## Sync interval in seconds — exposed so designers can tune per object type. @export var sync_interval: float = 0.05 # 20 Hz @export var speed: float = 200.0 # These properties are listed in the MultiplayerSynchronizer replication config. var synced_position: Vector2 = Vector2.ZERO var synced_velocity: Vector2 = Vector2.ZERO var synced_health: int = 100 var synced_anim: int = 0 # 0 = idle, 1 = run, 2 = jump @onready var _sync: MultiplayerSynchronizer = $MultiplayerSynchronizer func _ready() -> void: _sync.replication_interval = sync_interval # Only the authority (owner) drives movement. set_physics_process(is_multiplayer_authority()) func _physics_process(_delta: float) -> void: # Authority: write canonical state so MultiplayerSynchronizer can replicate it. synced_position = global_position synced_velocity = velocity synced_anim = _compute_anim_state()
csharp// SyncedPlayer.cs using Godot; public partial class SyncedPlayer : CharacterBody2D { /// <summary>Sync interval in seconds. Exposed so designers can tune per object type.</summary> [Export] public float SyncInterval { get; set; } = 0.05f; // 20 Hz [Export] public float Speed { get; set; } = 200.0f; // These properties are listed in the MultiplayerSynchronizer replication config. public Vector2 SyncedPosition { get; set; } = Vector2.Zero; public Vector2 SyncedVelocity { get; set; } = Vector2.Zero; public int SyncedHealth { get; set; } = 100; public int SyncedAnim { get; set; } = 0; // 0=idle, 1=run, 2=jump private MultiplayerSynchronizer _sync = null!; public override void _Ready() { _sync = GetNode<MultiplayerSynchronizer>("MultiplayerSynchronizer"); _sync.ReplicationInterval = SyncInterval; SetPhysicsProcess(IsMultiplayerAuthority()); } public override void _PhysicsProcess(double delta) { // Authority: write canonical state for replication. SyncedPosition = GlobalPosition; SyncedVelocity = Velocity; SyncedAnim = ComputeAnimState(); } private int ComputeAnimState() { if (!IsOnFloor()) return 2; return Velocity.Length() > 1f ? 1 : 0; } }
MultiplayerSynchronizer updates target properties at sync intervals (e.g., 30 Hz), but rendering runs at frame rate (60+ Hz). Without interpolation, remote players appear to teleport between snapshots. The fix: store position snapshots with timestamps and lerp in _process toward the latest snapshot using a small offset (interpolation buffer ~100 ms).
> See references/interpolation.md for the full GDScript and C# interpolation buffer pattern (snapshot ring, latest-snapshot interpolation, render-time lerp).
For local-player responsiveness: predict movement immediately on client, send input to server, reconcile when server snapshot arrives. If server diverges from client prediction beyond a threshold, snap; otherwise smoothly lerp the correction over 100-200 ms.
> See references/client-prediction.md for the full predict-and-reconcile pattern (input ring buffer, server reconciliation, replay) in GDScript + C#.
For hit-scan weapons in fast-paced games: when the server validates a hit, it rewinds the world state to the client's view-time (now - client_rtt/2 - interp_delay) and tests the hit against that historical state.
> See references/lag-compensation.md for the snapshot-history pattern, view-time calculation, and a hit-scan validator in GDScript + C#.
Choose the synchronization model that fits your game's needs:
| Factor | Sync State | Sync Inputs | |---|---|---| | What is sent | Current property values (position, health, etc.) | Player input actions each frame | | Who simulates | Authority only; others receive results | All peers run the same simulation | | Determinism required | No | Yes — every peer must produce identical output from the same inputs | | Bandwidth | Higher — full state sent each interval | Lower — small input structs per frame | | Responsiveness | Lower — non-authority peers wait for next sync tick | Higher — local prediction is trivial when deterministic | | Complexity | Lower — no reconciliation loop | Higher — requires deterministic physics, fixed-point math, or lockstep | | Best for | Action games, shooters, most real-time games | Fighting games, RTS, turn-based, simulation games | | Lag compensation needed | Yes, for hit detection | Usually not — all peers are in sync |
Hybrid approach (most real-time games): sync inputs for the local player's character (enabling prediction), sync state for all other objects and game events.
Four levers: sync only changed properties (replication-config flag per property), quantize floats (Vector3 components in mm not floats — 16-bit cuts bytes by 2×), distance-based sync rate (far-away objects sync at 5 Hz, close at 30 Hz), and channel selection (reliable for state changes that must arrive, unreliable for position streams that get superseded).
> See references/bandwidth-optimization.md for full GDScript + C# recipes for each lever, plus the reliable-vs-unreliable channel decision tree.
MultiplayerSynchronizer is a direct child of the node it replicatesset_multiplayer_authority() is called at spawn time with the correct peer IDreplication_interval and delta_interval are tuned for the object's update rate_process, not _physics_processEngine.get_physics_interpolation_fraction()unreliable RPC; state changes use reliable| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-15 | pass→pass | 12,476 | 16,448 | +32% | 1 | 1 | 0% | 1,868 | 5,672 | +204% | 0 | 0 | — |
case-01 | pass→pass | 10,987 | 10,397 | -5% | 1 | 1 | 0% | 1,851 | 4,420 | +139% | 0 | 0 | — |
case-02 | fail→pass | 8,813 | 8,023 | -9% | 1 | 1 | 0% | 1,554 | 4,169 | +168% | 0 | 0 | — |
case-03 | pass→pass | 8,289 | 5,780 | -30% | 1 | 1 | 0% | 1,358 | 3,604 | +165% | 0 | 0 | — |
case-04 | fail→pass | 17,247 | 4,986 | -71% | 1 | 1 | 0% | 3,022 | 3,587 | +19% | 0 | 0 | — |
case-05 | pass→pass | 15,986 | 10,672 | -33% | 1 | 1 | 0% | 2,338 | 4,343 | +86% | 0 | 0 | — |
case-06 | pass→pass | 5,770 | 8,537 | +48% | 1 | 1 | 0% | 816 | 4,086 | +401% | 0 | 0 | — |
case-07 | pass→pass | 7,552 | 6,525 | -14% | 1 | 1 | 0% | 1,207 | 3,681 | +205% | 0 | 0 | — |
case-08 | fail→pass | 15,043 | 6,597 | -56% | 1 | 1 | 0% | 2,612 | 3,762 | +44% | 0 | 0 | — |
case-09 | pass→pass | 8,210 | 6,791 | -17% | 1 | 1 | 0% | 1,218 | 3,767 | +209% | 0 | 0 | — |
case-10 | pass→pass | 7,692 | 8,359 | +9% | 1 | 1 | 0% | 1,147 | 4,058 | +254% | 0 | 0 | — |
case-11 | fail→fail | 10,924 | 12,483 | +14% | 1 | 1 | 0% | 1,855 | 5,046 | +172% | 0 | 0 | — |
case-12 | fail→fail | 16,765 | 16,194 | -3% | 1 | 1 | 0% | 2,770 | 5,436 | +96% | 0 | 0 | — |
case-13 | pass→pass | 12,711 | 10,802 | -15% | 1 | 1 | 0% | 1,857 | 4,560 | +146% | 0 | 0 | — |
case-14 | pass→pass | 12,712 | 6,523 | -49% | 1 | 1 | 0% | 1,786 | 3,646 | +104% | 0 | 0 | — |
case-16 | pass→pass | 9,302 | 8,141 | -12% | 1 | 1 | 0% | 1,377 | 3,738 | +171% | 0 | 0 | — |
case-17 | pass→pass | 18,543 | 27,009 | +46% | 1 | 1 | 0% | 2,732 | 7,257 | +166% | 0 | 0 | — |
case-18 | pass→pass | 6,821 | 3,573 | -48% | 1 | 1 | 0% | 1,123 | 3,245 | +189% | 0 | 0 | — |
case-19 | fail→fail | 5,746 | 5,633 | -2% | 1 | 1 | 0% | 991 | 3,635 | +267% | 0 | 0 | — |
case-20 | pass→pass | 6,855 | 4,375 | -36% | 1 | 1 | 0% | 1,213 | 3,462 | +185% | 0 | 0 | — |
case-21 | pass→pass | 16,145 | 21,114 | +31% | 1 | 1 | 0% | 2,794 | 6,740 | +141% | 0 | 0 | — |
case-22 | pass→pass | 10,594 | 8,056 | -24% | 1 | 1 | 0% | 1,761 | 4,204 | +139% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +14 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.