natiny.physics.cylinder
Lua
natiny.physics.cylinder([radius [, height]]) -> body
Creates a dynamic cylinder-shaped body at the world origin, standing upright
along Y.
Parameters
| Name |
Type |
Default |
Description |
radius |
number |
1 |
Radius in metres |
height |
number |
radius * 2 |
Full height along Y, in metres |
Returns
| Type |
Description |
number |
Body handle, also usable as an entity handle |
Example
Lua
local barrel = natiny.physics.cylinder(0.4, 1.2)
natiny.entity.set_position(barrel, natiny.entity.SPACE_WORLD, 0, 5, 0)
Notes
- Height is the full extent, not the half. The cylinder is centred on the
body's origin, so it reaches
height / 2 above and below it, and the body
starts at the world origin.
- Upright along Y as it is made. Lay it on its side by rotating the body:
natiny.entity.set_rotation(barrel, natiny.SPACE_WORLD, 0, 0, 90).
- The collider is a convex hull with sixteen flat sides rather than a true
cylinder, because the solver has no round shape. It rolls, but a slow one
resting on its side can settle on a facet.
- The body is dynamic;
natiny.physics.set_type changes that.
- Scaling the entity does not scale the collider.
- Lua raises an error when physics is not running, when either size is zero
or negative, or when the body cannot be made.