natiny_physics_set_material

C
void natiny_physics_set_material(NatinyBody body, float friction,
                                 float restitution, float density);

Sets how a body's surface behaves and how heavy it is.

Parameters

Name Type Description
body NatinyBody Body handle
friction float Coulomb friction, usually 0..1; starts at 0.6f
restitution float Bounce, 0 dead, 1 perfectly elastic; starts at 0.0f
density float kg/m^3; starts at 1000.0f

Example

C
NatinyBody ball = natiny_physics_sphere(0.5f);
natiny_physics_set_material(ball, 0.3f, 0.8f, 200.0f);   /* light and bouncy */

Notes

  • Mass follows from density and the volume of the shape and is recomputed here. A mesh or plane collider has no volume, so density does nothing to it.
  • Friction between two touching bodies is the square root of the product of theirs; restitution is the larger of the two.
  • Negative values are clamped to zero.