Restitution
Controls how bouncy a body is during contacts.
Restitution is a dimensionless body material coefficient. It is available on Dynamic, Static, and Kinematic bodies, although visible bouncing requires a body that can respond dynamically.
High-Level API#
body.set_restitution(value)
body.get_restitution()Range and default#
| Value | Meaning |
|---|---|
| 0 | No restitution contribution; default |
| 0..1 | Accepted finite range |
| 1 | Maximum idealized elasticity allowed by the wrapper |
Restitution changes the normal component of collision response. Actual bounce also depends on the other body, contact velocity, geometry, solver behaviour, and damping.
Example#
var ball = jolt_sphere_create_dynamic(0, 0, 6, 0.5, {
mass: 1,
restitution: 0.8,
friction: 0.2
});
ball.set_restitution(0.65);Low-Level / Advanced API#
Setters return true on success and false on invalid input, an invalid or stale body, or an unsupported motion type. Getters return the requested value or undefined when the operation fails. Inspect jolt_get_error() for the high-level error.
Verified operation contracts#
These contracts distinguish units, return values, errors and lifetime according to the current implementation. Check results: false, 0 and undefined can mean different things for different methods.
| Symbol / owner | Signature | Operation contract |
|---|---|---|
| JoltBody.get_restitution | JoltBody.get_restitution() | Finite coefficient 0..1; setter Boolean, getter number or undefined. |
| JoltBody.set_restitution | JoltBody.set_restitution(value) | Finite coefficient 0..1; setter Boolean, getter number or undefined. |