natiny_physics_cylinder
C
NatinyBody natiny_physics_cylinder(float radius, float height);
Creates a dynamic cylinder-shaped body at the world origin, standing upright
along Y.
Parameters
| Name |
Type |
Description |
radius |
float |
Radius in metres |
height |
float |
Full height along Y, in metres |
Returns
| Type |
Description |
NatinyBody |
Body handle, also usable as a NatinyEntity; 0 on failure |
Example
C
NatinyBody barrel = natiny_physics_cylinder(0.4f, 1.2f);
natiny_entity_set_position(barrel, NATINY_SPACE_WORLD, 0.0f, 5.0f, 0.0f);
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.0f, 0.0f, 1.5708f).
- 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.
- Returns
0 when physics is not running, when either size is zero or
negative, or when the body cannot be made.