DetPhysDocs日本語

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

FeatureContents
Deterministic 2D physicsA world on Box2D v3.2.0. All inputs are integers. A state hash every tick
Deterministic 3D physicsA world on Box3D (detphys3d.h). Boxes, spheres, capsules and convex hulls. Orientations are integer quaternions
Turn-based sessionsTwo 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 sessionsRollback 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 ruleA real-time rule where two players push boxes and concave shapes (2D detphys_rt_create_push, 3D detphys_rt_create_push3d). 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 shapesFive motions: spin, ping-pong, orbit, points and callback. Only fast ticks are split, so nothing tunnels through. 2D (detphys_kinematic.h) and 3D (detphys3d_kinematic.h)
Concave shape bakerIn 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 debuggerBuilt 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
TransportsA 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
Workers1–64 (default 1). The hash does not change with the count. Your engine's job system can be plugged in

Not included in this version

These are planned; no version is promised yet.

  • Steam transport. On Steam, plug your own transport into detphys_transport, or use EOS P2P or your own relay.
  • 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

EngineWhat you installVersionEngine versionsChecked on
UnityUPM package dev.petaf.detphys1.0.02022.3 LTS or newer2022.3.62f3 and 6000.3.28f1 (Editor, Windows Player [Mono], Android [IL2CPP]). iOS [IL2CPP] with 6000.3
GodotAdd-on addons/detphys (GDExtension and C#)layer version 74.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 EnginePlugin 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

FeatureUnityGodotUnreal
2D world and hashC#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 rulesC# (2D, 3D)GDScript, C# (2D, 3D)C++ (the core's C ABI)
3DC# (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 shapesC# (2D, 3D)GDScript, C# (2D, 3D)C++ (the core's C ABI)
Desync debugger2D, 3DReal time (2D, 3D)2D
Room codes, your own relayYesYesYes
EOS P2PWindows, AndroidWindows, AndroidWindows
AndroidYesYesYes (UE 5.8)
iOSYesYes (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

DeviceStatusChecked on
Windows x64Supported. MSVC, clang-cl and MinGW gcc builds all give the same hash. The shipped DLL has a static C runtime: nothing else to installi7-12700F / Windows 11
Android arm64-v8aSupported (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 yetMac mini M2, macOS 26.5, AppleClang 21 (Intel through Rosetta 2)
iOS arm64Supported (iOS 15.0 or newer, Unity and Godot; the Xcode project can be exported without a Mac). Same hashes on devices and the simulatoriPhone 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).

HeaderCurrent version
detphys.hDETPHYS_ABI_VERSION 2
detphys_body.hDETPHYS_BODY_ABI_VERSION 2
detphys_turn.hDETPHYS_TURN_ABI_VERSION 9
detphys_rt.hDETPHYS_RT_ABI_VERSION 8
detphys_kinematic.hDETPHYS_KINEMATIC_ABI_VERSION 2
detphys_debug.hDETPHYS_DEBUG_ABI_VERSION 3. Recording format DETPHYS_DEBUG_FORMAT_VERSION 2 = DNDR (2D recordings are written in format 1), bundle DETPHYS_DEBUG_BUNDLE_VERSION 1 = DNDB
detphys3d.hDETPHYS3D_ABI_VERSION 2
detphys3d_kinematic.hDETPHYS3D_KINEMATIC_ABI_VERSION 1
detphys_bake.hDETPHYS_BAKE_ABI_VERSION 1
detphys_link.hDETPHYS_LINK_ABI_VERSION 1
detphys_relay.hDETPHYS_RELAY_ABI_VERSION 1 (inside the core DLL)
detphys_eos.hDETPHYS_EOS_ABI_VERSION 2 (separate library detphys_eos)
detphys_udp.hnot 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_turn_create_rule3d), real-time sessions (detphys_rt_create3d), moving concave shapes (detphys3d_kinematic.h) 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.md in the Unity package). Keep the copyright notices and license texts in it with your game.
  • In games built with Unity, the DetPhys package adds this file automatically: on Windows as DetPhys/THIRD_PARTY_NOTICES.md next to the executable and in <Name>_Data/StreamingAssets/, on Android as assets/DetPhys/THIRD_PARTY_NOTICES.md in the APK, and on iOS in Data/Raw/DetPhys/ of the Xcode project.
  • In games exported with Godot, the DetPhys GDExtension adds this file automatically: as addons/detphys/THIRD_PARTY_NOTICES.md in the exported game's data, and on Windows and Linux also as DetPhys/THIRD_PARTY_NOTICES.md next to the executable. It is added even when the DetPhys editor plugin is not enabled.
  • 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/DetPhys/THIRD_PARTY_NOTICES.md), and on Android as assets/DetPhys/THIRD_PARTY_NOTICES.md in the APK.
  • 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.

DetPhys is not affiliated with Box2D or Box3D and is not endorsed or recommended by Box2D, Box3D or their author. It uses Box2D v3 and Box3D, both under the MIT license, as its physics.

LicensesMatches the current versions (2026-11)

© 2026 PetafProductsContactPrivacy

This site uses no analytics or tracking.

↑↓ to choose, Enter to open, Esc to close