Rigid bodies, kernels, materials
Skill ferret-physics-bodies · download all skills · SKILL.md
When to use#
Making things collide, choosing a kernel, defining materials, or writing a level's physics block.
Choosing a kernel#
LightKernel: small, no joints beyond rod, rope and spring, dynamic spheres only (boxes are not supported as dynamic bodies). Havok (loadHavok, havokKernel, in @ferret/physics-havok): full rigid bodies, joints, sweeps; per-pair material tables are not read there. Capabilities that need real rigid bodies say so.
Steps#
- Add
RigidBody(shape, mass or density, kinddynamic|static|kinematic, material) to entities. - Define materials as data: friction, restitution, density, strengths. A missing value means "does not apply" (no
tensileStrength= unbreakable). - Pair and combine rules for two materials meeting; validate with
validateMaterials. - Layers and masks for what hits what; triggers for zones; raycasts for queries.
- In a level: manifest
physicswith capabilities, materials, pairs, gravity,constraints(node names),fracturedbodies.
Check afterwards#
physics.materials prints what the host sees; body.state shows each body; the level's physics block validates before shipping.
What usually goes wrong#
- A box falls through a plane on the light kernel: use a sphere or Havok.
- A hinge or ball joint throws on the light kernel.
- Thin fast bodies tunnel: raise
substeps. - Mass wildly wrong: it is density times shape volume; check units (metres).
- Physics of the previous level lingers: it was applied at world scope; use
beginLevel.
Files#
reference/bodies-and-kernels.md— Rigid bodies in Ferret: the light and Havok kernels, shapes, body kinds, joints and their forces, contact events, and choosing between the two.reference/materials.md— Physical materials as data: the properties, what a missing value means, combine rules and pair tables, validation, and how capabilities read them.reference/level-block.md— Thephysicsblock of a level manifest: capabilities, materials, pair and combine rules, gravity, constraints and pre-fractured bodies, and what happens when the level loads and unloads.reference/api-physics-havok.md— every export of@ferret/physics-havokwith signature and doc comment