Quick start
Open a sample and run it as two players on one PC, then on a PC and an Android device. Using the Unity package from the Asset Store? Go straight to Unity. Put both devices on the same Wi-Fi (LAN), or connect them with a room code through a relay on your own server (8. Transports and room codes).
| Engine | Two players on one device | A PC and an Android device |
|---|---|---|
| Unity | Stacking (turn-based) and push (real-time, with moving field) samples | Play the same samples against each other |
| Godot | The same two samples as Unity (stacking and push, with moving field) | Play the same samples against each other. They also connect to the Unity samples |
| Unreal | Maps for the push sample (real time, with moving field; one uses the sessions directly, one is built with the match components), a map for the 3D push sample (with a turntable) and headless matches for stacking and push | PC against PC (LAN, or a room code on your own relay). They also connect to the Unity and Godot samples. Android with UE 5.8 |
The Unity and Godot sample screens are in English by default (the menu's Language / 言語 or the launch option lang=ja switches to Japanese; the OS language does not change it). Button names below are the English ones. The Unreal sample shows English (only the message for a peer with different settings switches to Japanese with the launch option lang=ja).
Code examples
The code for the engine you chose above. In every engine, inputs become integers before they go in, and both devices use the same settings, rule and shapes (in the same order).
Step a world and compare hashes
using DetPhys;
using var world = new DetPhysWorld(DetPhysWorldSettings.Default);
var chain = DetPhysHashChain.Start;
// Step 100 ticks, folding every tick's hash into a chain
for (int i = 0; i < 100; i++)
{
world.Step();
chain = chain.Add(world.Hash);
}
// This is the value you compare with the peer (the same on both)
Debug.Log($"tick {world.Tick} hash {DetPhysHash.ToHex(world.Hash)}");var world := DetPhysWorld.create(DetPhysWorldSettings.new())
# Step 100 ticks, folding every tick's hash into a chain
var chain := world.step_chain(100, DetPhys.chain_begin())
# This is the value you compare with the peer (the same on both)
print(world.get_tick(), " ", world.get_hash_hex())using DetPhys;
using var world = new DetPhysWorld(DetPhysWorldSettings.Default);
// Step 100 ticks, folding every tick's hash into a chain
ulong chain = world.StepChain(100, DetPhysHash.ChainBegin);
// This is the value you compare with the peer (the same on both)
GD.Print(DetPhysHash.Hex(world.Hash));#include "DetPhysWorld.h"
#include "DetPhysLibrary.h"
void AMyWorldActor::BeginPlay()
{
Super::BeginPlay();
UDetPhysWorld* World = UDetPhysWorld::CreateDetPhysWorld(this, FDetPhysWorldSettings());
// Step 100 ticks, folding every tick's hash into a chain
int64 Chain = World->StepTicksWithChain(100, UDetPhysLibrary::HashChainBegin());
// This is the value you compare with the peer (the same on both)
UE_LOG(LogTemp, Log, TEXT("tick %lld hash %s chain %llx"), World->GetTick(), *World->GetStateHashHex(), Chain);
}Event BeginPlay
→ Create DetPhys World (default Settings)
→ Step Ticks (Count 100)
→ Get State Hash Hex → Print StringA real-time match (built-in push)
using DetPhys;
// Both devices: the same settings, rule and shapes (in the same order)
var settings = DetPhysRtSettings.Default; // input delay 0, prediction 10
settings.sessionId = 0x16;
var push = new DetPhysPushSettings { seed = matchSeed };
var link = isHost ? DetPhysUdpLink.Connect("192.168.1.7", 47500) : DetPhysUdpLink.Listen(47500);
// 0 = host (the reference on a desync), 1 = guest
var session = DetPhysRtSession.CreatePush(settings, push, shapes, isHost ? 0 : 1, link.Endpoint);
var driver = new DetPhysRtDriver(settings.world.tickHz);
var input = new int[DetPhysPush.InputWords];
// Every frame (Update)
session.Poll();
for (int k = driver.Due(DetPhysRtSession.NowUs); k > 0; k--)
{
// Inputs are integers before they go in
input[0] = DetPhysPush.QuantizeMove(Input.GetAxisRaw("Horizontal"));
input[1] = jump ? DetPhysPush.ButtonJump : 0;
session.Advance(input, out var frame);
}
while (session.TryGetConfirmed(out var c))
{
// Confirmed ticks (the same hash on both peers): c.tick, c.hash
}
// Draw (the current state, predictions included)
int n = session.World.ReadBodies(views);# The real-time push node
var rt := DetPhysRtMatch.new()
# Both devices: the same settings, rule and shapes (in the same order)
rt.shape_files = shape_files
rt.rules = DetPhysPushRules.new()
add_child(rt)
# Inputs are integers before they go in
rt.input_source = func(tick: int) -> PackedInt32Array:
var move := DetPhysRtMatch.quantize_move(Input.get_axis("left", "right"))
var jump := 1 if Input.is_action_pressed("jump") else 0
return PackedInt32Array([move, jump])
# Confirmed ticks (the same hash on both peers)
rt.tick_confirmed.connect(func(tick, hash, flags): print(tick, " ", DetPhys.hash_hex(hash)))
# 0 = host (the reference on a desync), 1 = guest
rt.start(0, DetPhysLink.udp_connect("192.168.1.7", 47500))using DetPhys;
using Godot;
// Both devices: the same settings, rule and shapes (in the same order)
var push = DetPhysPush.Desc(seed: matchSeed);
var link = isHost ? DetPhysUdpLink.Connect("192.168.1.7", 47500) : DetPhysUdpLink.Listen(47500);
// 0 = host (the reference on a desync), 1 = guest
var session = DetPhysRtSession.CreatePush(push, isHost ? 0 : 1, shapes, link.Transport, link);
var input = new int[DetPhysPush.InputWords];
ulong nextUs = DetPhysTurnSession.NowUs;
// Every frame (_Process)
ulong now = DetPhysTurnSession.NowUs;
session.PollAt(now);
// Once per tick of a 60 Hz clock (at most 3 per frame when behind)
for (int k = 0; k < 3 && now >= nextUs; k++, nextUs += 1_000_000 / 60)
{
// Inputs are integers before they go in
input[0] = Mathf.Clamp(Mathf.RoundToInt(Input.GetAxis("left", "right") * 100f), -100, 100);
input[1] = Input.IsActionPressed("jump") ? 1 : 0;
session.AdvanceAt(now, input);
}
while (session.TryGetConfirmed(out var c))
{
// Confirmed ticks (the same hash on both peers): c.tick, c.hash
}#include "DetPhysMatchComponents.h"
#include "DetPhysLibrary.h"
#include "DetPhysLink.h"
// Header: UPROPERTY() TObjectPtr<UDetPhysRtMatchComponent> Match;
// UFUNCTION() void HandleTick(int64 Tick, int64 Hash, int32 Flags);
AMyMatchActor::AMyMatchActor()
{
Match = CreateDefaultSubobject<UDetPhysRtMatchComponent>(TEXT("Match"));
}
void AMyMatchActor::BeginPlay()
{
Super::BeginPlay();
// Both devices: the same settings, rule and shapes (in the same order)
Match->Settings.SessionId = 0x16;
Match->Rules.Seed = MatchSeed;
Match->ShapeFiles = ShapeFiles;
// Inputs are integers before they go in
Match->InputSource = [this](int64 InTick, TArray<int32>& Out)
{
Out = UDetPhysLibrary::MakePushInput(UDetPhysLibrary::QuantizeMove(MoveAxis), bJump, bDash);
};
Match->OnTickConfirmed.AddDynamic(this, &AMyMatchActor::HandleTick);
// 0 = host (the reference on a desync), 1 = guest
Match->StartWithLink(0, UDetPhysLink::UdpConnect(this, TEXT("192.168.1.7"), 47500));
}
// Confirmed ticks (the same hash on both peers)
void AMyMatchActor::HandleTick(int64 Tick, int64 Hash, int32 Flags)
{
UE_LOG(LogTemp, Log, TEXT("tick %lld hash %llx"), Tick, Hash);
}Add a DetPhys Rt Match component to an actor (set Settings, Rules and Shape Files the same on both peers)
Event BeginPlay
→ Udp Connect (Address 192.168.1.7, Port 47500) → Start With Link (Local Peer 0, Link)
Event Tick
→ Make Push Input (Quantize Move (horizontal axis), Jump, Dash) → Set Local Input
On Tick Confirmed (Tick, Hash, Flags) → Print String- The waiting side calls
Listen(Godotudp_listen, UnrealUdp Listen); the other side callsConnectwith its IP. When the PC is the connecting side, Windows needs no firewall rule. - Which side is the host (0) is a separate choice from which side waits.
Unity
You need Unity 2022.3 LTS or newer (checked with 2022.3.62f3 and 6000.3.28f1) on Windows. The package includes a macOS library, but it has not been tested in the Unity Editor or in Players on Mac yet. For Android, add Android Build Support to that version in Unity Hub; for iOS, iOS Build Support. To build an APK with 2022.3, turn on "JDK Installed with Unity" in Preferences > External Tools.
Import the package
- In the Package Manager (Window > Package Manager), open My Assets, select DetPhys, then Download and Import. If you have the
.unitypackagefile, use Assets > Import Package > Custom Package instead. - DetPhys is imported into
Packages/(in the Project window: Packages > DetPhys). Nothing is added todev. petaf. detphys Assets; that is expected. - Call
DetPhysCore.once at startup in your game: a missing or too old native library then gives a clear error.EnsureCompatible()
Import the samples
- In the Package Manager, choose In Project, select DetPhys, open Samples and click Import next to DetPhys Samples.
- The samples go into
Assets/. They are made for the built-in render pipeline.Samples/ DetPhys/ 1. 0. 0/ DetPhys Samples/
The sample picker (all four samples in one scene)
- Open
Assets/and press Play. Pick Stacking duel, Push, Push on moving parts, Gear arena or 3D push (the first four are the same list as the Godot picker).Samples/ DetPhys/ 1. 0. 0/ DetPhys Samples/ Scenes/ SampleMenu. unity - In every sample, the "← Samples" button at the top right, Esc and the Android back button close the session and the link and return to the picker (even in the middle of a match, without asking). The Android back button in the picker quits the app.
- Each sample also has its own scene in the same
Scenesfolder (StackVersus,PushVersus,GearArena,Push3D). Opened directly, the top-right button is that sample's "Menu" (its settings screen). - Text is sized so the short side of the screen is 720 (the same look at 720x1280, 1280x720, 1920x1080 and on Android in either orientation).
Two players on one PC: stacking (turn-based)
- In the picker choose Stacking duel, then "Two players on this device (loopback)".
- Controls: mouse for the position, wheel or Q / E to rotate, click or Space to drop. Whoever drops a piece loses. The core's rule picks the next shape from a seed (the current and next shapes are shown at the top).
Two players on one PC: push (real time, zero input delay)
- In the picker choose Push (or Push on moving parts), then "Two players on this device". P0: A D to move, W to jump, S to dash; P1: ← → ↑ ↓. Gamepads (left stick, A jump, X / B dash) and touch also work.
- The "Moving" options add a spinning gear, a sliding platform and a U-shaped lift (on two devices, pick the same on both).
- The rule is the core's built-in push (
DetPhysRtSession.). The same rule is also written in C# in the sample (CreatePush PushVersus/) as an example of writing your own rule; in a built player the launch optionRuntime/ CSharpPushRule. cs rule=csharpswitches to it. The results are the same and the two connect to each other.
3D push (Box3D, real time, zero input delay)
- In the picker choose "3D push" (or open
Scenes/).Push3D. unity - "Two players on this device": P1 moves with WASD, jumps with Space, dashes with Shift and drops a box with E; P2 uses the arrows, Right Ctrl, Right Shift and Enter. Touch: drag on the left, buttons at the bottom right.
- "Spinning turntable" (on by default) adds a spinning concave table at z = +7 m (a 16-sided hull disc with three low walls, a kinematic body moved as a function of the tick). It carries whatever lands on it. On two devices, choose the same on both.
- Two devices: "Host on this network (P1, waits)" / "Join on this network (P2, connects)" (default port 47800), "Make a room / Enter a room (relay)" or the EOS rooms. When the PC connects, no firewall rule is needed.
- Top left: the lamp of the confirmed hashes, the rollback depth, the peer, and "Nudge 1 ULP" (the desync debugger's report appears at the bottom, and the state resyncs by itself).
- The rule is written in C# in the sample (
DetPhysRtRule3D) and gives the same results as the core's built-in 3D push (detphys_). It also connects to the Godot "3D push" sample.rt_ create_ push3d
A PC and an Android device
- Add the scenes to the build: in File > Build Settings (Unity 6: File > Build Profiles), add
Scenes/from the imported samples first, thenSampleMenu. unity StackVersus,PushVersus,GearArenaandPush3Dfrom the same folder. - Switch the platform to Android. In Player Settings, set Scripting Backend to IL2CPP, tick ARM64 in Target Architectures and set Minimum API Level to Android 8.0 (API level 26) or higher. Build the APK and install it (Build And Run installs it on a device connected over USB).
- Android: open the app, pick the same sample as on the PC, choose "Wait" and "Guest (P1)", then start. Note the IP address shown as "This device". In Gear arena and 3D push the side that waits is the host: on Android choose "Host (P1, waits)" (Gear arena) or "Host on this network (P1, waits)" (3D push), and on the PC "Guest (P2, connects)" or "Join on this network (P2, connects)".
- PC: press Play in the Editor (or run a Windows player built from the same scenes), pick the same sample, choose "Connect", enter the Android IP in "Peer IP", choose "Host (P0)", then start.
- When the PC connects, no Windows firewall rule is needed (replies arrive as answers to what the PC sent).
- Which side is the host (the reference on a desync) is chosen separately from which side listens.
- Default ports: 47200 for stacking, 47500 for push, 47700 for Gear arena, 47800 for 3D push (same on both).
- In the push sample you can add test delay ("Test: delay ms", e.g.
30:60) and loss ("loss ‰") to the packets you send (use the same values on both). The confirmed results stay the same. - Not on the same network: make a room on one device and enter its 6-digit room code on the other, through EOS P2P (EOS P2P; the EOS SDK comes from Epic) or your own relay (8. Transports and room codes; its source is in the package's
Tools~/).detphys_ relay
Add a match to your own scene
- Add DetPhys Rt Match 3D to a GameObject (2D: DetPhys Rt Match; turn based: DetPhys Turn Match / DetPhys Turn Match 3D).
- In the Inspector pick the
Rule(Built In= the core's built-in rule,C Sharp= your rule [RuleorRuleFactoryfrom code]), thePushsettings of the rule and theConnection(Local= two players on this device,Udp,Relay[room codes] orEos). The rule settings, the shapes and theSession Idmust be the same for both players. - Give the input every frame with
InputSource((peer, tick) → integers) orLocalInput. On Play it starts inStart, steps by the tick clock inUpdate, rolls back, and copies the bodies to Transforms as theViewssettings say (Create Viewsalso makes simple views). - Events come as UnityEvents:
onConnected,onRoomCode(the code the host gives to the other player),onTickConfirmed(the same hash for both players),onDesync/onDesyncReport(the desync debugger's report),onPeerLost,onError,onMatchEnded. Turn based:SubmitononLocalTurn, results inonTurnFinishedandonMatchOver. - Your own concave shapes: open Window > DetPhys > Shape Baker (or right-click an image > DetPhys > Open in Shape Baker), pick a texture or sprite with transparency, check the preview, then Save. Select the GameObject with the match component and click Add to the Shapes of … in the window: the shapes are used as mesh 0, 1, … in that order (the same list on both players). See 3. Concepts for how the shapes are baked.
- With the launch option
driver=component, the "push" and "3D push" samples play the same match built from the components only (e.g.-detphys "game=push3d,driver=component,local=1"; the other player may run the same sample without the component).


How Create Views looks: with Material empty, the views use the package's default material (shader DetPhys/). It is shaded without any light in the scene and draws in the built-in render pipeline, URP and HDRP, also in Android and other player builds. With Color By Shape on, the color follows the body type and shape (static = gray, kinematic = teal, boxes = orange, spheres / circles = yellow, capsules = green, hulls / baked shapes = purple). For your own look, set Material in Views; all the views use that one material. For URP make a material with Universal Render Pipeline/, for HDRP one with HDRP/Lit, and so on. Reference the material from a scene or keep it in Resources so that builds include it. To give each body its own model, put Transforms in Bodies (by body id).
using DetPhys;
// a GameObject with the DetPhys Rt Match 3D component (Rule: Built In, Connection: Udp / Relay / Eos / Local)
var match = GetComponent<DetPhysRtMatch3D>();
// integers only: quantize the stick and the buttons before they go in
match.InputSource = (peer, tick) => DetPhysPush3D.Input(
DetPhysRtMatch3D.QuantizeAxis(Input.GetAxisRaw("Horizontal")),
DetPhysRtMatch3D.QuantizeAxis(Input.GetAxisRaw("Vertical")),
jump ? DetPhysPush3D.ButtonJump : 0);
match.onRoomCode.AddListener(code => Debug.Log("Room code: " + code));
match.onTickConfirmed.AddListener((tick, hash, flags) =>
{
// the same hash on both players
});
match.onDesyncReport.AddListener(report => Debug.LogWarning(report));- Short examples (worlds, sessions, your own rules, EOS) are in the package's
README.md(Packages/). The samples' scripts are underdev. petaf. detphys/ README. md Assets/.Samples/ DetPhys/ 1. 0. 0/ DetPhys Samples/
Export to iOS
- You need Unity's iOS Build Support. Set Target minimum iOS Version in Player Settings to 15.0 or newer. iOS uses IL2CPP and devices (arm64) only (you cannot build for the Simulator).
- The package includes the iOS library (
Runtime/). Unity links it into UnityFramework in the exported Xcode project, so no extra settings or post-processing are needed.Plugins/ iOS/ libdetphys. a - You can export the Xcode project on Windows. Building and signing it in Xcode needs a Mac (or a CI service that runs on a cloud Mac).
- The license notices go to
Data/in the Xcode project (in the app,Raw/ DetPhys/ THIRD_ PARTY_ NOTICES. md DetPhys/underTHIRD_ PARTY_ NOTICES. md Application.).streamingAssetsPath - If the target iOS version is older than 15.0, or the build is for the Simulator, a
[DetPhys]warning appears in the Console when the build starts. - EOS P2P is not available on iOS in this version (
DetPhysEos.is false). LAN UDP and your own relay work. For UDP on a LAN, iOS asks for local network permission (IsAvailable NSLocalNetworkUsageDescriptionin Info.plist).
Godot
You need Godot 4.3–4.8 (for C#, a .NET build of 4.4 or newer; checked with 4.7.2 .NET).
Two players on one device
- Open
engines/in Godot (if Godot crashes on the first import, open it again).godot/ DetPhysSample - Open a sample scene and run it with "Run Current Scene" (F6):
- Stacking (turn-based):
res://samples/ stack_ versus/ stack_ versus. tscn - Push (real time, zero input delay):
res://(the menu also has the moving field)samples/ push_ versus/ push_ versus. tscn - 3D push (Box3D, real time, zero input delay, GDScript only):
res://(the menu also has the spinning turntable, on by default)samples/ push3d/ push3d_ versus. tscn - All of them can be picked from the main scene (the sample picker)
- Stacking (turn-based):
- Choose "Two players on this device". The controls are the same as in the Unity samples (stacking: mouse for the position, wheel or Q / E to rotate, click or Space to drop; push: A D to move, W / Space to jump, S / Shift to dash, P1 uses the arrow keys; touch: drag on the left half, top right to jump, bottom right to dash). 3D push: WASD / left stick to move, Space to jump, Shift to dash, E to drop a box, P2 uses the arrows, Enter, . and /; touch: drag on the left half, buttons at the bottom right. "Nudge 1 ULP" at the top right moves the guest's state by one floating-point step: the desync debugger's report (tick, body, field, ULP, cause) appears at the bottom and the session resyncs by itself.
A PC and an Android device (Godot with Godot, or Godot with Unity)
- Export an APK with the Android preset in
export_and install it (arm64, Android 8.0 or newer; C# Android export needs 4.7 or newer).presets. cfg - Choose "Wait (guest)" on Android and "Connect (host)" with the Android IP on the PC, then start (when the PC connects, no firewall rule is needed).
- The ports and settings are the same as the Unity samples (47200 for stacking, 47500 for push), so the other side can be a Unity sample (for the push moving field, pick the same on both).
- 3D push (port 47800) follows Unity's "3D push": "Host on this network" (P1, waits) on one side, the peer IP and "Join on this network" (P2, connects) on the other. Pick the same turntable setting on both. The other side can be the Unity sample.
- The 3D push can also run with the same rule written in C# (
DetPhysSamplePush3DRuleinsamples/and the 3D match noderules3d/ DetPhysSampleRules3D. cs DetPhysRtMatch3D). Addrule=csto the launch options (without the turntable only, .NET build of Godot) for an automatic match without drawing, e.g.godot --headless --path DetPhysSample -- "detphys=game=push3d;rule=cs;peer=0;connect=127.. The other peer can keep the built-in rule (the Godot, Unity or Unreal 3D push, or a session created with0. 0. 1:47800;auto=1;quit=1" detphys_in the C ABI); the confirmed tick hashes are the same.rt_ create_ push3d - Stacking and push can also run with the same rules written in GDScript or C# (
samples/rules2d). Addrule=gdorrule=cs(.NET build of Godot) to the launch options, and the sample puts that rule in the match node (DetPhysStackMatch,DetPhysRtMatch). The menu buttons (two players on this device, connect, relay and EOS rooms) start with the same rule, and it connects to peers with the built-in rule (the Unity samples too) with the same hashes.
The check scene (hashes match)
Run the main scene res:// (F5). The output lists [DetPhysGodot] <name> <value> OK lines and ends with [DetPhysGodot] RESULT pass=<n> fail=0 when the core on this device gives the reference hashes (with a .NET build of Godot also the C# layer; on the standard build the C# lines say SKIP). On Android the results are the [DetPhysGodot] lines in logcat.
Add it to your project
Copy addons/detphys (no editor plugin needs to be enabled). The add-on's README.md explains how to use it. Every export includes the license notices: inside the exported data at res:// (in the APK, assets/), and on Windows and Linux also as DetPhys/ next to the executable.
var rt := DetPhysRtMatch.new() # node for push (real time)
rt.shape_files = ... # the same shapes in the same order on both peers
rt.rules = DetPhysPushRules.new() # built-in push settings (integers only); moving field: rules.field = DetPhysPushRules.FIELD_ALL
add_child(rt)
rt.input_source = func(tick: int) -> PackedInt32Array:
return PackedInt32Array([DetPhysRtMatch.quantize_move(Input.get_axis("left", "right")), 1 if Input.is_action_pressed("jump") else 0])
rt.start(1, DetPhysLink.udp_listen(47500)) # 0 = host, 1 = guestExport to iOS
- The add-on includes the iOS GDExtension (
addons/, a static library). Thedetphys/ bin/ ios/ libdetphys_ godot. xcframework ios.arm64line indetphys.puts it into the export, so adding an iOS export preset is all you need.gdextension - iOS 15.0 or newer (set Min iOS Version in the export preset to 15.0 or newer), devices (arm64) only.
- Godot on Windows and Linux can export the Xcode project. Building and signing it in Xcode needs a Mac (or a CI service that runs on a cloud Mac).
- Exporting a project that uses C# to iOS is still experimental in Godot and needs Godot on macOS. DetPhys's C# layer has not been tested on iOS in this version; on iOS, use DetPhys from GDScript.
- The license notices go into the exported data (
.pck) atres://.addons/ detphys/ THIRD_ PARTY_ NOTICES. md - EOS P2P is not available on iOS in this version. LAN UDP and your own relay work. For UDP on a LAN, iOS asks for local network permission (
NSLocalNetworkUsageDescription).
Demo: Gear Arena (Unity and Godot, cross-engine)
Two rods push 120 concave pieces inside a spinning concave gear. It exists in both Unity and Godot, and the two play each other (Unity on a PC with Godot on Android, too). At the edge of the screen: an injected-delay slider (0..150 ms), the input delay, the hash lamp, the rollback meter, the opponent's engine, "Nudge 1 ULP" and "Show convex pieces".
- Unity: pick Gear arena in the sample picker, or open
Scenes/of the imported samples. Godot: "Gear arena" in the menu (C#, so the .NET build). Port 47700.GearArena. unity - Details, the screen items and measured numbers: Gear Arena.
Unreal Engine
You need Unreal Engine 5.4–5.8 (automation tests checked with 5.8.4; the plugin builds on all of 5.4.4–5.8.4), Win64.
World and hash (one device)
- Open
engines/(it loads the plugin fromunreal/ DetPhysSample/ DetPhysSample. uproject engines/).unreal/ DetPhys - Run the eight
DetPhys.Sampletests (Abi, Empty100, Scene600, Tower720, Net, Net3D, Rule3D, Link) in Tools > Session Frontend > Automation: all match the reference hashes (Net runs stacking and push with two peers in one process; Net3D runs the 3D push [with and without the turntable, with delay and loss, with a nudge] and checks the coordinate conversion and the hull faces; Rule3D runs 3D rules written in C++ [push, turn-based stacking, a spinning table] and the 3D match components; Link checks room codes, rooms in the test lobby and the match components). - Blueprint:
Create DetPhys World(integer settings: tick rate, substeps, gravity in mm/s², worker threads) →Stepevery simulation tick → compareGet State Hashbetween peers. - In your own project, put
engines/inunreal/ DetPhys <YourProject>/and enable the plugin. From C++, addPlugins/ DetPhys "DetPhysRuntime"to your module's dependencies (and"DetPhysCore"to call the core C ABI directly);UDetPhysWorld::GetNative()returns thedetphys_world*. All functions in 7. API reference (turn-based, real-time, built-in push, moving concave shapes, desync debugger, 3D) can be called from C++. The match API (UDetPhysLink,UDetPhysTurnSession::CreateStack,UDetPhysRtSession::CreatePushand the like) can also be called from Blueprint (7. API reference).
The sample picker
- Open the map
Content/and press Play (it is also the first map of a packaged game). Pick Push (PushVersus, a sample written in C++), Push on moving parts, Push, built with components (PushComponents) or 3D push (Push3D), and how to play: "Two players on this PC", "Wait (guest, port 47500)", "Connect (host)", "Make a room (relay)" or "Enter the room (relay)". Type the peer IP, the relay and the room code in the "Two devices" box on the right. English is the default; switch with "日本語" at the top (kept for the next start).Maps/ SampleMenu - In every sample, "← Samples" at the top right, Esc or the Android back button closes the session and the transport and goes back to the picker (right away, even mid-match; you can listen on the same port again afterwards). Esc in the picker quits the game.
- The launch option
-detphys="game=push|field|components|push3d;..."skips the picker and starts that sample (it reads the rest of the options as before). Opening a sample map directly still works. - Text size follows the short side of the screen as 720 (
Config/, UserInterfaceSettings: ShortestSide, 1.0 at 720), so 1280x720, 1920x1080 and tall windows look the same.DefaultEngine. ini
Two players on one PC (push, real time, zero input delay)
- Pick "Push > Two players on this PC" in the picker, or open the sample map
Content/and press Play (no art: the bodies are extruded convex polygons).Maps/ PushVersus - By default two players share this PC. P0: A D to move, W or Space to jump, S or Shift to dash (gamepads too); P1: arrow keys.
- The launch option
-detphys="field=all"adds the moving field (spinning gear, sliding platform, rising U) (or pick some withgear,platformandliftjoined by+).
Two PCs (LAN), also against the Unity and Godot samples
- Start the waiting side (guest) with
-detphys="peer=1;listen=47500"and the connecting side (host) with-detphys="peer=0;connect=<peer IP>:47500". The port and settings are the same as the Unity and Godot push samples, so the other side can be a Unity or Godot sample (pick the same moving field on both). - Stacking (turn-based) has no drawn sample yet (planned), only headless matches (a commandlet):
UnrealEditor-Cmd DetPhysSample.(uproject -run=DetPhysVersus -detphys="game=stack;peer=0;connect=127. 0. 0. 1:47200;auto=1" game=pushfor push; the launch keys and log lines are the same as in the Unity and Godot samples).
3D push (also against the Unity and Godot samples)
- Pick "3D push > Two players on this PC" in the picker, or open the map
Content/and press Play. Two players push boxes, balls and rocks (convex hulls); a spinning concave turntable at the back carries whatever lands on it (no art: boxes, balls and the hull meshes read from the core).Maps/ Push3D - P1: WASD to move, Space to jump, Shift to dash, E to drop a box (gamepad: left stick, A, X, B); P2: arrows, Enter,
.,/. N nudges the state by 1 ULP on purpose, and the desync debugger's report and the resync show on screen. - For two devices, start the waiting side with "Wait (host, port 47800)" or
-detphys="game=push3d;peer=0;listen=47800"and the connecting side with "Connect (guest)" or-detphys="game=push3d;peer=1;connect=<peer IP>:47800"(in 3D push, as in the Unity and Godot 3D push, the waiting side is the host). The rule is the built-in 3D push (UDetPhysRtSession::CreatePush3D) with the same settings, so the other side can be the Unity or Godot "3D push" and the confirmed tick hashes are the same. Use the same turntable setting on both (field=tableorfield=none; the picker starts with the turntable). Relay rooms use the same keys as in 2D (relay=,room=; the default bucket isdetphys-sample/).push3d - Headless match:
UnrealEditor-Cmd DetPhysSample.(the launch keys and log lines are the same as in the Unity and Godot 3D push). Adduproject -run=DetPhysVersus -detphys="game=push3d;peer=0;connect=127. 0. 0. 1:47800;auto=1;field=table" rule=cpp(without the turntable only) to run the same rule written in C++ (UDetPhysSamplePush3DRuleinDetPhysSampleRules3D.,h UDetPhysRtSession::Create3D); the other peer can keep the built-in rule. - Coordinates: the core has y up and metres (right-handed), Unreal has z up and centimetres (left-handed). The plugin's readback (
ReadTransforms3D,ReadBodies3D,GetHull3DMeshand the like) returns Unreal coordinates, ready for Actors and components. The rule settings and the input ([move x, move z, buttons]) stay in core coordinates (Unreal X = core x, Unreal Y = core z;Make Push 3D Inputbuilds the input from an Unreal X / Y direction).
Over the internet (your own relay and a room code)
- Run your own relay (
detphys_relay; see 8. Transports and room codes) somewhere. - Start the side that makes the room with
-detphys="relay=<relay host or IP>[:<port>];peer=0": the 6-digit room code appears in the log and on screen. The side that enters uses-detphys="relay=<the same relay>;room=<room code>". This works for the push map and for the commandlet (game=stacktoo), and the other side can be a Unity or Godot sample (the default bucketsdetphys-sample/andpush detphys-sample/are the same).stack
Building with the match components (Blueprint only is fine)
- The sample map
Content/is the same push game built only withMaps/ PushComponents UDetPhysRtMatchComponentand its Delegates (ADetPhysRtMatchSampleActor; by default two players on this PC through a room in the test lobby). Its launch options are the same as PushVersus (relay=,room=,connect=,listen=). - Add a DetPhys Rt Match component (DetPhys Stack Match for stacking) to your Actor (a Blueprint is fine) and make
Shapes(read withLoad Shape Files),SettingsandRulesthe same on both peers. - Call
Host Relay Room(make a room) orJoin Relay Room(enter by code), orStart With Linkon a LAN (aUdp Listen/Udp Connectlink).On Room Readycomes when the role is decided,On Connectedwhen connected. - Every frame put your input (integers, e.g. from
Make Push Input) intoLocal Input. Confirmed ticks arrive inOn Tick Confirmed(the same hash on both peers); for stacking,SubmitonOn Local Turnand read results inOn Turn Finished. Draw fromGet Session's body readback.
Android
- Android (arm64-v8a, Android 8.0 or newer) works with UE 5.8: the plugin includes the Android library, so package the game for Android as usual. Checked with UE 5.8.4 on a Galaxy S9 (the same hashes as on a PC, 60 fps in the push samples).
- EOS P2P is Windows only in Unreal in this version; on Android use LAN UDP or your own relay.
When something goes wrong
| Symptom | Check |
|---|---|
| Does not connect (stays CONNECTING) | Same LAN (over the internet, use a room code on your own relay)? Same port? Is Windows the connecting side? Are both configurations equal (session id, rule settings, push moving field, shapes and their order)? Peers with different configurations drop each other's messages. Cores with rt version 7 / turn version 9 then report which part differs (version, config, rule, shapes, kinematic) (DETPHYS_, detphys_tag_info; see 5. Troubleshooting desyncs). The samples (Unity, Godot, Unreal) show "Peer has different settings (differs: rule). Stopped connecting: …" once they know what differs, and stop connecting |
| Does not connect to an older APK | Peers with different protocol versions do not connect. Rebuild both from the same version |
| The other peer crashed | The session keeps waiting (after 5 s without packets it reports PEER_LOST). Restart the app on the crashed side and create the session with the same settings: it rejoins where it left off |
| Desync | Desyncs are found by the hash check and repaired automatically from the host's state. To find the cause, see 5. Troubleshooting desyncs |