一键导入
dev-multiplayer-prediction-basics
Client-side prediction and server reconciliation core concepts. Use when implementing responsive multiplayer controls.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Client-side prediction and server reconciliation core concepts. Use when implementing responsive multiplayer controls.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
| name | dev-multiplayer-prediction-basics |
| description | Client-side prediction and server reconciliation core concepts. Use when implementing responsive multiplayer controls. |
| category | multiplayer |
Client prediction makes multiplayer feel responsive. Server reconciliation keeps it honest.
Use for EVERY server-authoritative gameplay feature that needs responsive feel:
INPUT
│
├───► LOCAL PREDICTION (immediate visual feedback)
│ │
│ └───► Display updates instantly (feels responsive)
│
└───► SEND TO SERVER (validation)
│
│ NETWORK LATENCY (~100ms)
│
▼
SERVER PROCESSES
│
└───► SERVER STATE (authoritative)
│
│ NETWORK LATENCY
│
▼
CLIENT RECONCILES
│
├───► Discard confirmed inputs
├───► Re-apply pending inputs
└───► Smooth correction
Result: Responsive feel + cheat prevention
interface InputMessage {
type: 'player_input';
input: {
forward: boolean;
backward: boolean;
left: boolean;
right: boolean;
jump: boolean;
};
sequence: number; // Incrementing counter for matching
}
Critical for reconciliation:
// Server sends authoritative state
interface ServerState {
position: { x: number; y: number; z: number };
lastProcessedSequence: number; // Key for reconciliation
}
// Client reconciles
function reconcile(serverState: ServerState) {
// 1. Remove inputs server has processed
pendingInputs = pendingInputs.filter(
p => p.sequence > serverState.lastProcessedSequence
);
// 2. Start from server position (authoritative)
let position = { ...serverState.position };
// 3. Re-apply all pending inputs
for (const input of pendingInputs) {
position = applyInput(position, input.input, 0.016);
}
// 4. Smoothly interpolate display
displayPosition = lerp(displayPosition, position, 0.2);
}
CRITICAL: Config values MUST match exactly between client and server.
// ❌ Config defined separately
// Client: const MOVEMENT_SPEED = 10;
// Server: const MOVEMENT_SPEED = 10; // Can drift!
// ✅ shared/config/MovementConfig.ts
export const MOVEMENT_CONFIG = {
walkSpeed: 10,
sprintSpeed: 16,
jumpForce: 8,
gravity: 20,
} as const;
// Both client and server import from same file
// ✅ Server sends config on connect
onJoin(client: Client) {
client.send({
type: 'config_sync',
movement: MOVEMENT_CONFIG,
});
}
| ❌ Wrong | ✅ Right |
|---|---|
| No prediction, send input only | Predict locally, then send |
| No reconciliation, just snap | Smooth interpolation |
| Apply server state directly | Re-apply pending inputs first |
| Separate client/server config | Shared config module |
| Hardcoded values everywhere | Single source of truth |
Complete Developer workflow orchestration - task research sequence, implementation flow, validation gates, PRD synchronization, exit conditions.
Complete Game Designer workflow - skill invocation protocol, GDD creation, playtest flow with GDD review, design sessions. MUST load before starting assignments.
Complete PM Coordinator workflow - task assignment, project orchestration, PRD management, worker coordination. Use proactively when starting PM agent work.
Complete PM Coordinator workflow - task assignment, project orchestration, PRD management, worker coordination. Use proactively when starting PM agent work.
Complete QA Validator workflow orchestration. References specialized skills for each validation step. Load at session startup for full protocol.
Base instructions and guidelines for all agents in the system. This skill provides foundational behaviors and communication protocols that all agents should follow.