| Function | Description |
|---|
detphys_rt_abi_version | This header's version |
detphys_rt_config_default | Default settings (delay 0, N 10, hash check every tick, each hash in 2 packets, dyn, 1 worker, 4 bases, time sync at 1 tick, 100 ms keepalive, 5000 ms peer timeout) |
detphys_rt_create | Creates a session (creates the world, registers shapes, calls begin) |
detphys_rt_create_kinematic | Same, also passing a kinematic table (moving concave shapes)Usage: Concepts › Moving concave shapes |
detphys_rt_destroy | Destroys it |
detphys_rt_poll | Reads what arrived; sends acks and resync stateUsage: Concepts › Transports |
detphys_rt_advance | Passes your input and advances one tick (rolling back and re-simulating if needed). Returns ADVANCED / STALLED / SYNC_WAIT / DELAY_WAITUsage: Concepts › Real time (rollback) |
detphys_rt_next_input_tick | The tick the next advance's input goes toUsage: Concepts › Real time (rollback) |
detphys_rt_next_confirmed | Takes the oldest confirmed tick record (tick, hash), for replays and logs |
detphys_rt_get_stats | Counters for rollbacks, re-simulation, waits, hash checks, resyncs, bytes and timeUsage: Desyncs › Desyncs are repaired automatically first |
detphys_rt_world | Current world (including predictions; read it for drawing)Usage: Concepts › Real time (rollback) |
detphys_rt_read_state | Current game state words |
detphys_rt_error | Reason when in ERROR |
detphys_rt_auto_delay_default | Default automatic input delay (off, 0–6, jitter × 1, raise after 500 ms, lower after 3000 ms) |
detphys_rt_set_auto_delay | Sets automatic input delay (NULL = off)Usage: Concepts › Zero input delay and automatic input delay |
detphys_rt_set_link_id | Your link id |
detphys_rt_get_link_info | Current link and delay statusUsage: Transports and room codes › On the game side |
detphys_rt_debug_nudge_at | Test only: shifts the state by 1 ULP after that tickUsage: Determinism rules › How to check |
detphys_rt_set_debug | Turns the desync debugger on / offUsage: Desyncs › Turning the desync debugger on |
detphys_rt_debug_count | Number of reportsUsage: Desyncs › Reading the report |
detphys_rt_debug_get | Reads a report |
detphys_rt_debug_bundle | Packs a report and both recordings into a bundle |
detphys_rt_debug_stats | Recording and exchange counters |
detphys_rt_get_tag_info | Reads what a peer with a mismatching config check sends (the same detphys_tag_info as turn-based). Read it when DETPHYS_RT_FRAME_TAG_MISMATCH is set. Version 7 |
| Struct | Description |
|---|
detphys_rt_session | A session (opaque) |
detphys_rt_config | Settings (session id, shapes, peer, world, input delay 0–30, prediction window 0–60, hash checks, snapshots, workers, network values)Usage: Concepts › 3D |
detphys_rt_rule | A rule (1–16 input words, 0–64 state words, params, begin, apply_inputs, after_tick, predict)Usage: Concepts › Rules |
detphys_rt_ctx | Values passed to callbacks (world, params, state, tick, peer, re-simulating) |
detphys_rt_frame | Result of advance (tick, input tick, confirmed tick, re-simulated ticks, flags [DETPHYS_RT_FRAME_*; version 7 added DETPHYS_RT_FRAME_TAG_MISMATCH], round trip)Usage: Desyncs › Desyncs are repaired automatically first |
detphys_rt_confirmed | A confirmed tick record |
detphys_rt_stats | Session counters |
detphys_rt_auto_delay | Automatic input delay settings |
detphys_rt_link_info | Link and delay status |
#Built-in rule: push (version 5)
A real-time rule where two players (circles) push boxes and concave shapes with a 2-word input [move −100..100, buttons (1 = jump, 2 = dash)]. The callbacks live inside the core (C++), so an engine only creates the session. Unity's DetPhysRtSession.CreatePush and Godot's DetPhysRtSession.create_push call it too. With the same settings, every engine and device produces the same confirmed-tick hashes, so they connect to each other. A moving field (field) adds a spinning gear (DETPHYS_RULE_PUSH_FIELD_GEAR), a sliding platform (PLATFORM) and a lift (LIFT) made of concave shapes; the session creates and owns their kinematic table.
| Function | Description |
|---|
detphys_rule_push_desc_default | Default push settings (60 boxes, 12 concave shapes, 8 meshes, half floor width 12000 mm, no moving field, REPEAT prediction) |
detphys_rt_create_push | Creates a push session (the simplest entry point; with a moving field it also creates the table and destroys it with detphys_rt_destroy). NULL on failureUsage: Transports and room codes › Usage (the same for every transport) |
detphys_rt_rule_push | Writes only the push rule (to wrap the rule or use your own table; with a moving field put the table in rule.user and call detphys_rt_create_kinematic) |
detphys_rule_push_get_layout | IDs of the bodies begin creates (floor 0, walls 1 and 2, players 3 and 4, boxes, shapes, moving field), without creating a sessionUsage: Concepts › Rules |
detphys_rt_kinematic | The kinematic table a session is moving (read only; NULL if none) |
| Struct | Description |
|---|
detphys_rule_push_desc | Push settings (144 B: box and shape counts, seed, floor / wall / player sizes, force, speed, jump, dash, moving field field [GEAR 1, PLATFORM 2, LIFT 4, ALL 7], speed %, drop height, mesh indices, predict [REPEAT / RELEASED], table split settings kinematic_*) |
detphys_rule_push_layout | The body ID layout and the params size (88 or 120 bytes) |
Constants: DETPHYS_RULE_PUSH_ID, DETPHYS_RULE_PUSH_INPUT_WORDS (2), DETPHYS_RULE_PUSH_STATE_WORDS (4), DETPHYS_RULE_PUSH_TAG_* (box 1, shape 2, field 3, player 100 + peer).
#3D sessions (version 6)
The tick flow, prediction, rollback, hash checks, resync, rejoin and automatic delay are the same as in 2D; the world is 3D (detphys3d.h). Differences:
- World settings are a
detphys3d_world_desc. The config's world, meshes, worker_count and snapshot_base_slots are not used (mesh_count must be 0); register convex hulls in begin, in the same order on both peers (their contents are part of the config check). - Full snapshots are recommended for the state ring (
detphys_rt_config_default3d sets FULL). The checked hash is detphys3d_world_hash plus the state words. - Resync and rejoin send a transfer (
detphys3d_world_transfer_*, which also carries the shape registry and the hull table), so the receiver can restore even when its registry drifted during prediction. - The desync debugger (
detphys_rt_set_debug) works in 3D too (when detphys_debug_abi_version() is 3 or later; recordings use the 3D format and reports the 3D fields; see 5. Troubleshooting desyncs). - Pass a 3D kinematic table with
detphys_rt_create3d_kinematic in detphys3d_kinematic.h (see the detphys3d_kinematic.h section below).
| Function | Description |
|---|
detphys_rt_config_default3d | Fills session settings (snapshot FULL) and 3D world settings with defaults (either may be NULL) |
detphys_rt_create3d | Creates a 3D session (NULL world settings = defaults). Then poll → advance → next_confirmed as in 2DUsage: Concepts › 3D |
detphys_rt_world3d | The current 3D world (includes prediction; read it for drawing). For 3D sessions detphys_rt_world returns NULLUsage: Concepts › 3D |
detphys_rt_get_resync_info | What was sent / received on resync and rejoin (counts, registry rebuilds, size, restore time). Works for 2D too |
| Struct | Description |
|---|
detphys_rt_rule3d | A 3D rule (same layout as detphys_rt_rule; callbacks receive detphys_rt_ctx3d; 72 B) |
detphys_rt_ctx3d | Values passed to callbacks (same layout as detphys_rt_ctx; only world is a detphys3d_world*) |
detphys_rt_resync_info | Resync status (dimensions 2 / 3, sent, received, registry_rebuilds, hull_replacements, last size, tick and time) |
#Built-in rule: 3D push (version 8)
A 3D real-time rule where two players (spheres) push boxes, spheres and convex hulls (6 kinds made from the seed) inside a floor with four walls, with a 3-word input [move x, move z (−100..100), buttons (1 = jump, 2 = dash, 4 = drop a box)]. As with the 2D push rule, the callbacks live inside the core (C++), so an engine only creates the session. The params and rule id are the same as the C# rule of Unity's "3D push" sample, so with the same settings the confirmed-tick hashes are the same and those peers connect. With the turntable (field = DETPHYS_RULE_PUSH3D_FIELD_TURNTABLE) a concave table (a 16-sided disc with three low walls) spins as a function of the tick; the session creates and owns its 3D kinematic table (read it with detphys_rt_kinematic3d).
| Function | Description |
|---|
detphys_rule_push3d_desc_default | Default 3D push settings (40 boxes, 8 spheres, 12 hulls, up to 24 dropped boxes per player, seed 0x5EED0036, no turntable [800 mrad/s, center (0, +7 m)], REPEAT prediction) |
detphys_rt_create_push3d | Creates a 3D push session (the simplest entry point; NULL world settings = defaults; with the turntable it also creates the table and destroys it with detphys_rt_destroy). NULL on failureUsage: Quick start › 3D push (Box3D, real time, zero input delay) |
detphys_rt_rule_push3d | Writes only the 3D push rule (a detphys_rt_rule3d; to wrap the rule or use your own table; with the turntable put a detphys3d_kinematic* in rule.user and call detphys_rt_create3d_kinematic) |
detphys_rule_push3d_get_layout | IDs of the bodies and hulls begin creates (floor 0, walls 1–4, players 5 and 6, boxes, spheres, hulls, turntable, then boxes dropped during the match), without creating a session |
detphys_rule_push3d_auto_inputs | The samples' automatic inputs (ticks 0..ticks, 3 words per tick), for comparing with the reference hashes |
| Struct | Description |
|---|
detphys_rule_push3d_desc | 3D push settings (144 B: box / sphere / hull counts, boxes that can be dropped, seed, floor / wall / player sizes, force, speed, jump, dash, drop interval, object sizes, density and friction, turntable field [NONE 0, TURNTABLE 1], spin and center, predict [DETPHYS_RULE_PUSH_PREDICT_*], table split settings kinematic_*) |
detphys_rule_push3d_layout | The body ID layout (turntable table_body, dropped boxes first_dropped), hull IDs (stones hull_types, turntable disc table_hull) and the params size (88 or 104 bytes) |
Constants: DETPHYS_RULE_PUSH3D_ID, DETPHYS_RULE_PUSH3D_INPUT_WORDS (3), DETPHYS_RULE_PUSH3D_STATE_WORDS (8), DETPHYS_RULE_PUSH3D_BUTTON_*, DETPHYS_RULE_PUSH3D_TAG_* (box 1, sphere 2, hull 3, turntable 7, dropped box 50 + peer, player 100 + peer), DETPHYS_RULE_PUSH3D_FIELD_*.