# Multiplayer Basics

Use when implementing multiplayer, MultiplayerAPI, ENet/WebSocket peers, RPCs, and...

- Repository: https://github.com/jame581/GodotPrompter (914 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-11-01
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add jame581/GodotPrompter --skill multiplayer-basics -g -a claude-code -y`
Codex: `npx skills add jame581/GodotPrompter --skill multiplayer-basics -g -a codex -y`
Cursor: `npx skills add jame581/GodotPrompter --skill multiplayer-basics -g -a cursor -y`
Gemini CLI: `npx skills add jame581/GodotPrompter --skill multiplayer-basics -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add jame581/GodotPrompter`

## Description

Use when implementing multiplayer, MultiplayerAPI, ENet/WebSocket peers, RPCs, and authority model

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Multiplayer Basics in Godot 4.3+

All examples target Godot 4.3+ with no deprecated APIs. GDScript is shown first, C# follows.

**Related skills:** See **multiplayer-sync** for state synchronization and interpolation. See **dedicated-server** for headless export and server deployment.

---

## 1. Multiplayer Architecture

Godot uses a **client-server model** built on top of `MultiplayerAPI`. One peer acts as the server; all others are clients. Every peer has a unique integer ID assigned by the network layer:

| Peer ID | Role |
|---------|------|
| `1` | The server (always) |
| `2`+ | Connected clients, randomly generated unique IDs, **not** sequential |

**Multiplayer authority** is the concept of ownership over a node. Only the authoritative peer should read input and drive that node's state. By default the server (peer `1`) is the authority for every node. Call `set_multiplayer_authority(peer_id)` to transfer ownership to a client, on **every** peer, since the call is local and is not replicated.

```
Server (peer 1)
    ├── Owns game state by default
    ├── Spawns and validates objects
    └── Routes RPCs
Client (peer 2, 3, …)
    ├── Sends input to server via RPC
    └── Receives state updates from server
```

---

## 2. Setting Up ENetMultiplayerPeer

Both sides use the same three steps: create an `ENetMultiplayerPeer`, call `create_server(port, max_clients)` or `create_client(address, port)`, then assign it to `multiplayer.multiplayer_peer` and connect the `MultiplayerAPI` signals (`peer_connected`, `peer_disconnected`, `connected_to_server`, `connection_failed`, plus `server_disconnected`, see §7). **Check the `create_*` return value**, it returns an `Error`, and a silent `ERR_CANT_CREATE` (port already in use) otherwise looks exactly like a hang.

The server is always peer ID `1`; clients receive randomly generated unique IDs, so never assume they are sequential.

The rest: https://github.com/jame581/GodotPrompter/blob/HEAD/skills/multiplayer-basics/SKILL.md
