Concepts

Multiplayer

Inventories in networked multiplayer games.

The inventory system was built from the ground up to support multiplayer. It integrates with Godot's high-level multiplayer feature. It only uses RPCs to remain network implementation agnostic. The source code includes demos that use ENet, WebSocket, and WebRTC.

In multiplayer games, security and cheating concerns become priorities. The inventory component is server-authoritative, making it suitable for games with dedicated servers as well as player-hosted "peer-to-peer" games.

Clients interacting with the inventory send requests to the host for validation to prevent cheating. Server-side logic prevents item tampering and duplication bugs.

Server inventory state is synchronized to clients on demand. Inventory contents are hidden from clients until an access manager context is created. Inventory items are serialized and deserialized efficiently for network transmission.

Atomic transactions: Item additions, removals, and transfers are atomic to avoid partial operations. Method parameters are designed to be RPC-friendly.

The inventory supports concurrent player interactions (e.g. two players trying to pick up the same item). Multiple inventory updates are batched to reduce emitted signals and network messages.

Multiplayer Synchronization

The inventory system uses a server-authoritative approach to managing inventories. Clients are unaware of inventory contents until they request access.

The GGInventory component synchronizes its contents with clients once they have an open context via the GGEntityAccessManager. In multiplayer scenarios, the access manager identifies players by their unique peer_id.

Clients make requests (via RPCs), which the server validates and processes.

Multiplayer Visibility

Godot Engine's multiplayer features allow for per-client visibility of scenes.

Note: The GGInventory component does not use the MultiplayerSpawner/MultiplayerSynchronizer nodes itself as to not dictate their use. You'll likely want to implement them at the entity level.

© 2023 — 2025 GodotBuilder. All rights reserved.