Box3d Physics bindings for Unity
Unity bindings for Box3D — the 3D physics engine by Erin Catto, author of Box2D. The full native C API (~580 functions) is exposed through a Unity-friendly C# layer: no pointers in user code, no per-frame allocations, deterministic simulation, and excellent multithreaded performance.
This project was inspired by, and owes its architecture to, two projects:
Status: early (0.8.x). Box3D itself is a young engine (v0.1) with no API stability guarantees yet, and this wrapper tracks it. It is usable and well-tested, but expect breaking changes on engine updates.
Box3DWorld component; a drop-in stats HUD (step time, per-phase profile, live counts);
World.GetProfile() / GetCounters() for programmatic profiling; and a Collision Debugger
window answering "why isn't this pair colliding?" rule by rule.Measured against Unity's built-in PhysX with identical seeded scenes (editor, same machine, box3d running 4 sub-steps vs PhysX defaults — details and CSVs in the docs):
| Scene | PhysX | Box3D (16 workers) | |
|---|---|---|---|
| 10,000 spheres raining | 6.70 ms | 1.84 ms | ~3.6× faster |
| Destroyed city, ~10,000 bodies (buildings + props) | 10.94 ms | 7.67 ms | ~1.4× faster |
| 64 piles, 1,024 bodies (sleep off) | 1.15 ms | 0.54 ms | ~2.1× faster |
| Joint-grid cloth, 930 joints | 0.54 ms | 0.71 ms | PhysX ahead on single-island loads |
The city scene is a mixed real-world load — a town of running-bond brick buildings and props on terrain, smashed by a scripted sequence of wrecking balls (identical seeded content on both engines). There, Box3D's slowest step matched PhysX's median — tighter frame times through the collapses.
A pure-box3d stress test ships too: a 16,290-box pyramid, one box deep, held upright by contact recycling. It steps in single-digit milliseconds, roughly halving once the stack settles to sleep — throw spheres to wake and collapse it, and dial the worker thread count to see how box3d's built-in scheduler scales. Ships in the Benchmarks sample.
Box3D's threading scales with the number of independent simulation islands — piles, debris, and crowds are its home turf; one giant coupled constraint network is its least favorable shape.
Via the openupm-cli:
openupm add com.suvitruf.box3dOr add the scoped registry manually — Edit → Project Settings → Package Manager → Scoped Registries, add:
package.openupm.comhttps://package.openupm.comcom.suvitrufthen install box3d for Unity from Window → Package Manager → My Registries.
Alternatively, in the Package Manager choose Add package from git URL and paste:
https://github.com/Suvitruf/box3d-unity.gitRequires Unity 6000.0+. Native binaries are included for Windows x64, Linux x64,
Android arm64, and WebGL; macOS/iOS build scripts are provided but binaries are not
shipped yet (see Documentation~/building-natives.md).
…See Documentation~/getting-started.md for the full walkthrough, and install the samples from
the Package Manager window: an interactive playground, basic simulation, joints, mouse drag,
character controller, a drivable vehicle, two water scenes (a fillable buoyancy pool and a GPU
particle water pool with a waterfall), and benchmark scenes comparing against PhysX — including a
16,290-box pyramid stress test you can smash by
throwing spheres.
The sample scenes assume URP (they render fine elsewhere, minus materials), and the interactive
ones require the Input System package.
BOX3D_DOUBLE modeJoin on Discord — chat about the project, follow progress, ask questions, share ideas, or help test. Everyone curious about Box3D or physics in Unity is welcome.
Support development — this is a free, open-source labour of love built in spare time. If you'd like to help it move along faster, you can support me on Patreon. Entirely optional — it funds the time spent on the bindings and tooling; the package stays free and MIT either way.
MIT (see LICENSE). Box3D itself is MIT, © Erin Catto.
No open issues yet, or sync has not completed.