The unlikely story of Teardown Multiplayer
4 days ago
- #multiplayer
- #teardown
- #game-development
- Multiplayer was the most requested feature for Teardown, but initially deemed unrealistic due to the complexity of synchronizing physics and a fully destructible, moddable world.
- An internal experiment in 2021 used a naive approach to sync objects and voxel data, but it consumed too much bandwidth and was not usable.
- A community project called TDMP added basic multiplayer support via reverse engineering, syncing player positions and inputs, though it often desynced due to non-deterministic destruction.
- In late 2022, a hybrid approach was adopted: deterministic destruction with state synchronization for other elements, ensuring perfect world sync without excessive bandwidth use.
- Floating-point operations were initially avoided for determinism, but later understood to be manageable with careful handling. Destruction logic was rewritten using fixed-point math for voxel operations.
- The game uses a peer-to-peer model where the host acts as the server, with reliable streams for scene changes and unreliable streams for non-critical state sync like object transforms.
- Scripting support was adapted for multiplayer, with scripts split into server and client parts but kept in the same file for simplicity, using shared state tables and remote calls.
- Terminals and UI were tricky; they run server-side, with draw commands delta-compressed and streamed to clients, similar to the X Window System.
- Originally planned as a separate game, multiplayer was later merged into the main branch, a complex process that took months and required ongoing sync efforts.
- Backwards compatibility was a major challenge, requiring old mods to still work in single-player while adding optional multiplayer support via API extensions.
- Late joins were enabled by recording and replaying deterministic commands, though with limits to prevent excessive computation time.
- Development tools initially allowed multiple game instances in one window for easier debugging, but this was later reverted to separate processes due to complexity.
- The multiplayer implementation is a mix of techniques with many special cases, reflecting the challenges of adapting a released, moddable game for multiplayer.