FERRETGame engine over Babylon.js
Ferret

Friction and impact

Skill ferret-physics-friction-impact · download all skills · SKILL.md

When to use#

Slippery floors, rails, skis; bouncy or dead bodies; clay and magnets; sound or damage from hits.

The model#

The kernel already applies Coulomb friction, rolling resistance and restitution from the materials. friction and impact add what a game dials per scope, so a patch of ice can be a zone as well as a material. The value is read at the dynamic body's entity and the contact point. impact has a restitution scale, a rest threshold, loss of bounce at high speed, stick, and emits physics:impact with its energy.

Steps#

  1. Enable the capability; set values at zone or entity scope.
  2. Make things settle: raise threshold, or scale below 1.
  3. Sound and sparks: listen to physics:impact (respect minEventSpeed).
  4. Damage from hits belongs to strength (ferret-physics-strength), driven by the same contacts.
  5. Rolling and pivot friction need the material's rollingFriction.

Check afterwards#

A block on a slope creeps or holds as μ against tan(angle) predicts; a dropped ball's bounce height follows e² h for spin-free spheres.

What usually goes wrong#

  • Nothing slides on ice: capability off, or the scope key is not the dynamic body's.
  • A ball never stops rolling: no rollingFriction, and rollingScale multiplies zero.
  • Anisotropy, pivot friction and stick do nothing on Havok.
  • scale above 1 gives restitution above 1: energy appears.

Files#

  • reference/friction.md — Friction by scope: slippery zones, per-body grip, rolling and pivot resistance, and anisotropic friction for skates, rails and skis.
  • reference/impact.md — Collisions as a dial: restitution scale, rest threshold, bounce falloff at speed, sticking bodies, and the impact event with its energy.
  • reference/api-physics-friction.md — every export of @ferret/physics-friction with signature and doc comment
  • reference/api-physics-impact.md — every export of @ferret/physics-impact with signature and doc comment