PhysicsSystem¶
2D (Box2D) and 3D (Jolt) simulation. scene:getPhysicsSystem().
Properties¶
| Type | Name | Default | Languages |
|---|---|---|---|
| Vector2 | gravity2D | (0,-9.81) |
C++ | Lua |
| Vector3 | gravity3D | (0,-9.81,0) |
C++ | Lua |
| Vector3 | gravity | (0,-9.81,0) |
C++ | Lua |
| float | pointsToMeterScale2D | 64.0 |
C++ | Lua |
| bool | lock3DBodies | true |
C++ | Lua |
gravity2D and gravity3D set each world's gravity independently (m/s²); the legacy gravity / setGravity(...) sets both worlds at once and reads back the 3D value. The same values are exposed directly on Scene — scene.gravity2D / scene.gravity3D — which is what the editor's scene Physics section edits and saves.
Events¶
2D: beginContact2D, endContact2D, hitContact2D, sensor contacts, preSolve2D, shouldCollide2D
3D: onContactAdded3D, onContactRemoved3D, onBodyActivated3D, shouldCollide3D
See Events. Use onFixedUpdate for forces.