natiny.physics.set_material
natiny.physics.set_material(body [, friction [, restitution [, density]]])
Sets how a body's surface behaves and how heavy it is.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
body |
number |
Body handle | |
friction |
number |
0.6 |
Coulomb friction, usually 0..1 |
restitution |
number |
0.0 |
Bounce, 0 dead, 1 perfectly elastic |
density |
number |
1000 |
kg/m^3 |
Example
natiny.physics.set_material(ball, 0.3, 0.8, 200) -- light and bouncy
Notes
- Omitted Lua arguments use the initial values shown in the table.
- 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.