Cocos AIR physics contracts
Stop once you can answer the task. Do not read another same-topic reference for the same question.
Scope: Builtin/cannon selection, 3D bodies and filters, and pure-JS 2D Box2D.
Environment: use package imports in apps; source paths require an AIR checkout. See context.
Quick Start
For complete setup and teardown, read Quick Start.
Siblings: direct dependencies; reuse loaded skills.
Triggers
- Choose query-only builtin or simulated cannon physics
- Make bodies fall, stack or respond to forces
- Configure colliders, triggers and bidirectional collision masks
- Use 2D rigid bodies or spatial queries
- Diagnose 9642 and backend registration
- Check whether a requested WASM backend ships
Exact API and symptom mappings: triggers.
Contracts
Choose builtin or cannon before engine initialization. Builtin detects collisions but does not integrate motion; WASM backend presence must be verified separately. Do not treat exported rigid-body symbols as simulation proof.
Read references/contracts.md only when the task needs exact option rules, limits, error behavior or source annotations. Prefer the topic references below for a narrower question.
Common Mistakes
- [HIGH] Default builtin physics does not provide gravity or stacking.
- [HIGH] Set both collision groups and masks for valid pairs.
- [MEDIUM] Ammo, physx and box2d-wasm are not shipped.
- [MEDIUM] The flat selector export does not identify 3D backend.
Read relevant wrong/right examples before implementation.
Reference map
- Which backend ships? - Selection and limits
- Why no 3D motion? - Bodies, filters and queries
- Need 2D physics? - Box2D components and queries