onephysics
Deterministic 2D rigid-body physics for .NET: the same world state, bit for bit, on every platform, CPU, vector width and thread count.
A preview, 0.4.0-preview.1. Previews are not bit-compatible with each other, and the 3D engine is marked experimental.
A quick look
A world, a ball and the ground, stepped with a fixed time step. The snapshot restores bit for bit, and the hash is the same on every machine.
Getting startedvar world = new PhysicsWorld2D(); world.AddBox(new Vector2F(20, 1), at: new Vector2D(0, -1), type: BodyType.Static); var ball = world.AddCircle(0.5f, at: new Vector2D(0, 5)); for (int i = 0; i < 600; i++) world.Step(1f / 60); byte[] saved = world.Snapshot(); ulong hash = world.ComputeHash();
What it does
Shapes and joints
Circles, capsules, rounded polygons, segments and chains; revolute, prismatic, weld, wheel, distance, motor and mouse joints; bullets and continuous collision.
Rollback-ready
Byte-exact snapshots and restores, a world hash per step, quiet resimulation, and no allocation in steady state after Warmup.
Events and queries
Collision, sensor, sleep and joint-break events in a fixed order, as handlers or polled spans. Raycasts, shape casts and overlaps, with layers and filters.
Familiar names
One-liners in Unity’s vocabulary for bodies, joints and a character mover, and a mapping table for moving from Unity’s 2D physics.
Three tiers, one engine
One-liners, definitions and polled events, and a raw tier, each built on the one below. Handles are small structs, and a destroyed one throws an exception that names it.
3D, in preview
Rigid bodies, characters, vehicles, ragdolls, buoyancy and soft bodies, deterministic like 2D, behind an experimental marker while their API settles.
The same hash everywhere
Only IEEE + - * / and square root decide a result, with onemath’s own transcendental functions, fixed-order reductions and constraint coloring. The world hash after N steps is checked to be the same on x64, arm64 and WebAssembly, scalar or SIMD, one thread or all cores. Every 2D scene is within its speed bar at every thread count.
The package
- RecursiveAI.OnePhysics
The 2D engine (
Physics2D), the 3D preview (Physics3D, experimentalOPHYS0002) and the raw tier (LowLevel, experimentalOPHYS0001). Preview, 0.4.0-preview.1. - Dependency
onemath, for vectors and deterministic math. Nothing else.
- Previews
A snapshot, saved game or replay from one preview does not carry to the next.
- .NET
.NET 10. NativeAOT, trimming and browser WebAssembly are supported. MIT or Apache-2.0.