2D physics engine for games, written in portable C
open sourceMITfree
Box2D is Erin Catto's 2D rigid body physics engine for games. It handles collision (convex polygons, capsules, circles, rounded polygons, segments and chains, with continuous collision detection, contact and sensor events, ray and shape casts) and physics with its Soft Step solver, joints with limits, motors and springs, island-based sleeping and character movers. Version 3 is written in portable C17 with a data-oriented design, multithreading and SIMD, optional double precision for large worlds, cross-platform determinism, snapshots and recording and replay. It builds with CMake on Windows, Linux and macOS, and can be added from Zig or Swift Package Manager.
Problems it solves
- add realistic 2D physics and collisions to my game
- simulate stacks of rigid bodies with joints in a 2D game engine
- get deterministic 2D physics that replays the same on every platform for multiplayer
Features
- Continuous collision detection for convex polygons, capsules, circles, segments and chains
- Soft Step rigid body solver with island-based sleep
- Revolute, prismatic, distance, motor, weld and wheel joints with limits, motors and springs
- Character movers with a robust plane solver
- Multithreading, SIMD and optional double precision for large worlds
- Cross-platform determinism, snapshots and recording and replay
Alternatives
The same job
These do what Box2D does.
- Matter.js 2D rigid body physics engine for the web in JavaScript, with collisions, constraints and a canvas renderer
