Overview
What DetPhys is
Physics that gives bit-identical results for the same settings and the same inputs on every device and in every engine, and netcode built on it (turn-based and real-time rollback). Windows and Android, Unity, Godot and Unreal can run the same match with the same values.
- Peers send inputs only: 32–48 bytes per tick one way in real time.
- Every tick (every turn in turn-based play) the state hash is compared with the other peer. A desync is found at once and repaired from the host's state.
- When peers desync, the desync debugger shows which tick, which body, which value and how many ULPs apart, and whether the cause is the input or the physics.
- Concave shapes (gears, U shapes, combs, creature silhouettes) are baked from images into sets of convex polygons and used without approximation.
- Moving concave shapes (spinning gears, sliding platforms, lifts) move as functions of the tick. A rollback rebuilds them bit for bit.
- Both 2D (Box2D v3) and 3D (Box3D) worlds run in the same sessions.
- The core is C++ exposed through a C ABI. The Unity, Godot and Unreal layers are thin layers over the same prebuilt core (
detphys_core).
What kind of game it suits
- Stacking battles where players take turns dropping shapes onto a pile (turn-based)
- Action games where players push and throw things, and platform fighters (real time, zero input delay)
- Action games on spinning gears and moving platforms (moving concave shapes)
What it does
| Feature | Contents |
|---|---|
| Deterministic 2D physics | A world on Box2D v3.2.0. All inputs are integers. A state hash every tick |
| Deterministic 3D physics | A world on Box3D (detphys3d.h). Boxes, spheres, capsules and convex hulls. Orientations are integer quaternions |
| Turn-based sessions | Two players take turns. On a desync the host's state is sent (resync). Rejoins and host restarts continue the match. 2D and 3D. Built-in rule: stacking |
| Real-time sessions | Rollback with zero input delay by default. Prediction window N (default 10). Automatic delay (off by default). Resync and rejoin. 2D and 3D. Rules in C, C++, C# or GDScript |
| Built-in push rule | A real-time rule where two players push boxes and concave shapes (2D detphys_, 3D detphys_). An optional moving field: a spinning gear, a sliding platform, a lift. 2D works across all three engines, 3D between Unity and Godot |
| Moving concave shapes | Five motions: spin, ping-pong, orbit, points and callback. Only fast ticks are split, so nothing tunnels through. 2D (detphys_) and 3D (detphys3d_) |
| Concave shape baker | In the editor (Unity: Window > DetPhys > Shape Baker; Godot: the DetPhys Shapes dock; Unreal: right-click a texture > Bake DetPhys Shape): images to sets of convex polygons (.dnshape, integer mm), the same bytes in every editor. Decomposition: Steiner (default) or Hertel-Mehlhorn |
| Desync debugger | Built into the sessions (off by default, 2D and 3D). On a desync both peers hold the same report. Both peers' recordings can be saved in one file (a bundle) to send to the developer |
| Transports | A swappable interface (send and receive) and a "make a room, enter by room code" interface (detphys_link.h). LAN UDP, a relay you run on your own server (detphys_relay) and an in-process loopback come with it. EOS P2P (Epic Online Services; the EOS SDK comes from Epic) on Windows and Android in Unity and Godot, and on Windows in Unreal |
| Workers | 1–64 (default 1). The hash does not change with the count. Your engine's job system can be plugged in |
- A session has two players (peers 0 and 1).
- Over the internet, play through EOS P2P (EOS P2P; no server of your own) or a relay on your own server (8. Transports and room codes). Any other transport plugs into
detphys_.transport
Not included in this version
These are planned; no version is promised yet.
- Steam transport. On Steam, plug your own transport into
detphys_, or use EOS P2P or your own relay.transport - EOS P2P on iOS (Unity and Godot) and EOS P2P on Android in Unreal. LAN UDP and your own relay work there.
- Unreal on iOS, and the engine layers on macOS. The Unity package includes a macOS library, but it has not been tested in the Unity Editor or in Players on Mac yet.
- Unreal: the desync debugger in 3D, and Blueprint nodes for every feature. Some features are used from C++ through the core's C ABI there (What each engine offers).
- wasm.
What it does not do
- No physics engine written from scratch. The physics is Box2D v3 / Box3D.
- No triangle tests between freely moving concave meshes. Concave shapes are sets of convex polygons; moving concave shapes are kinematic, following a motion you define.
- No servers run for you. It is P2P: one side listens, the other connects. Over the internet, use EOS P2P, your own relay or another transport.
- No art or audio assets. Sample shapes are drawn procedurally.
Supported engines and versions
| Engine | What you install | Version | Engine versions | Checked on |
|---|---|---|---|---|
| Unity | UPM package dev. | 1.0.0 | 2022.3 LTS or newer | 2022.3.62f3 and 6000.3.28f1 (Editor, Windows Player [Mono], Android [IL2CPP]). iOS [IL2CPP] with 6000.3 |
| Godot | Add-on addons/detphys (GDExtension and C#) | layer version 7 | 4.3–4.8 (GDScript 4.3 or newer, C# 4.4 or newer, C# on Android 4.7 or newer) | 4.7.2 .NET (Windows, Android). GDScript also on 4.4.1, 4.5, 4.8-dev5. iOS (GDScript) with 4.7.2 |
| Unreal Engine | Plugin DetPhys (DetPhysCore and DetPhysRuntime) | 0.1.0 (beta) | UE 5.4–5.8 (Win64; Android with UE 5.8) | Automation tests on UE 5.8.4. The plugin builds on 5.4.4, 5.5.4, 5.6.1, 5.7.4 and 5.8.4. Android with 5.8.4 |
What each engine offers
| Feature | Unity | Godot | Unreal |
|---|---|---|---|
| 2D world and hash | C# | GDScript, C# | Blueprint, C++ |
| Turn-based (built-in stacking) | C# | GDScript (node DetPhysStackMatch), C# | Blueprint, C++ (component) |
| Real time (built-in push, moving field) | C# | GDScript (node DetPhysRtMatch), C# | Blueprint, C++ (component) |
| Your own rules | C# (2D, 3D) | GDScript, C# (2D, 3D) | C++ (the core's C ABI) |
| 3D | C# (world, rules, moving concave shapes) | Built-in 3D push, rules, moving concave shapes (GDScript, C#) | C++ (the core's C ABI) |
| Placing your own moving concave shapes | C# (2D, 3D) | GDScript, C# (2D, 3D) | C++ (the core's C ABI) |
| Desync debugger | 2D, 3D | Real time (2D, 3D) | 2D |
| Room codes, your own relay | Yes | Yes | Yes |
| EOS P2P | Windows, Android | Windows, Android | Windows |
| Android | Yes | Yes | Yes (UE 5.8) |
| iOS | Yes | Yes (GDScript) | – |
- All three engines use the same prebuilt core, so the hashes match across engines. Checked by playing Godot ↔ Unity, Unreal ↔ Unity and Unreal ↔ Godot (PC), and Godot (Android) ↔ Unity (PC).
- Unity players built with different editors (a 2022.3 APK and a 6000.3 PC player) play each other.
- Only engine versions we checked are listed.
- Exporting C# for Android from Godot is still experimental and needs net9.0.
- Godot 4.5–4.8 .NET may crash on the first import after it finds a new GDExtension (a Godot bug). Opening the project again fixes it.
Supported devices
| Device | Status | Checked on |
|---|---|---|
| Windows x64 | Supported. MSVC, clang-cl and MinGW gcc builds all give the same hash. The shipped DLL has a static C runtime: nothing else to install | i7-12700F / Windows 11 |
| Android arm64-v8a | Supported (API 26 = Android 8.0 or newer, 16 KB page aligned) | Galaxy S9 (SC-03K, Snapdragon 845, Android 10) |
| macOS (Apple silicon, Intel) | Core only: same hashes on Apple silicon and Intel (macOS 11.0 or newer, one universal library). The engine layers are planned: the Unity package includes a macOS library, but it has not been tested in the Unity Editor or in Players on Mac yet | Mac mini M2, macOS 26.5, AppleClang 21 (Intel through Rosetta 2) |
| iOS arm64 | Supported (iOS 15.0 or newer, Unity and Godot; the Xcode project can be exported without a Mac). Same hashes on devices and the simulator | iPhone 11 (iOS 26.6.1), iOS Simulator (iPhone 17) |
| wasm | (planned) | – |
| Windows x86 (32-bit) | Not supported (Box2D v3.2.0 does not link with 32-bit MSVC) | – |
Versions
The core C ABI counts a version per header. When a version only adds functions, older functions keep working (compare with >= at startup).
| Header | Current version |
|---|---|
detphys.h | DETPHYS_ 2 |
detphys_body.h | DETPHYS_ 2 |
detphys_turn.h | DETPHYS_ 9 |
detphys_rt.h | DETPHYS_ 8 |
detphys_kinematic.h | DETPHYS_ 2 |
detphys_debug.h | DETPHYS_ 3. Recording format DETPHYS_ 2 = DNDR (2D recordings are written in format 1), bundle DETPHYS_ 1 = DNDB |
detphys3d.h | DETPHYS3D_ 2 |
detphys3d_kinematic.h | DETPHYS3D_ 1 |
detphys_bake.h | DETPHYS_ 1 |
detphys_link.h | DETPHYS_ 1 |
detphys_relay.h | DETPHYS_ 1 (inside the core DLL) |
detphys_eos.h | DETPHYS_ 2 (separate library detphys_eos) |
detphys_udp.h | not counted (changes together with detphys_turn.h) |
- Peers with different protocol versions do not connect (they refuse while connecting). Build both sides with the same DetPhys version.
- When a peer's config check does not match, the core reports which part differs (5. Troubleshooting desyncs).
About 3D
3D (Box3D) covers worlds (detphys3d.h), turn-based sessions (detphys_), real-time sessions (detphys_), moving concave shapes (detphys3d_) and the desync debugger. Every tick is identical on five PC builds and a Galaxy S9, and matches between a PC and an S9 (with loss, nudges, rejoins and host restarts) matched too. See 3. Concepts for how to use it and detphys3d.h in 7. API reference for the functions.
- Bodies resting on a spinning platform in 3D slowly slide outward (a property of Box3D's contacts; see 3. Concepts).
- The state sent on a resync is 190–260 KB for 115 bodies.
Licenses
- DetPhys is not affiliated with, or endorsed by, Box2D, Box3D or their author (Erin Catto).
- DetPhys ships
THIRD_(PARTY_ NOTICES. md Third Party Notices.in the Unity package). Keep the copyright notices and license texts in it with your game.md - In games built with Unity, the DetPhys package adds this file automatically: on Windows as
DetPhys/next to the executable and inTHIRD_ PARTY_ NOTICES. md <Name>_, on Android asData/ StreamingAssets/ assets/in the APK, and on iOS inDetPhys/ THIRD_ PARTY_ NOTICES. md Data/of the Xcode project.Raw/ DetPhys/ - In games exported with Godot, the DetPhys GDExtension adds this file automatically: as
addons/in the exported game's data, and on Windows and Linux also asdetphys/ THIRD_ PARTY_ NOTICES. md DetPhys/next to the executable. It is added even when the DetPhys editor plugin is not enabled.THIRD_ PARTY_ NOTICES. md - In games packaged with Unreal, the DetPhys plugin adds this file automatically: on Windows inside the game's folder, at a path that follows where the plugin is (for example
RemappedPlugins/), and on Android asDetPhys/ THIRD_ PARTY_ NOTICES. md assets/in the APK.DetPhys/ THIRD_ PARTY_ NOTICES. md - Box2D v3.2.0 (MIT, Copyright (c) 2022 Erin Catto): snapshot / restore APIs for rollback were added (existing APIs and behaviour are unchanged).
- Box3D (MIT, Copyright (c) 2026 Erin Catto; pinned to main commit 3362633): snapshot / restore APIs for rollback were added. The licenses of the bundled rapidhash, verstable and qsort.h are in the same file.