natiny_physics_set_rotation_locks
void natiny_physics_set_rotation_locks(NatinyBody body, bool lock_x, bool lock_y, bool lock_z);
Locks or unlocks rotation of a body around each world axis independently. The solver cannot turn the body around a locked axis, while the axes left free keep responding to gravity, contacts and impulses.
Parameters
| Name | Type | Description |
|---|---|---|
body |
NatinyBody |
Body handle |
lock_x |
bool |
true to prevent rotation around the world X axis (pitch) |
lock_y |
bool |
true to prevent rotation around the world Y axis (yaw) |
lock_z |
bool |
true to prevent rotation around the world Z axis (roll) |
Example
/* Stays upright, but is still free to spin around Y */
natiny_physics_set_rotation_locks(player, true, false, true);
Notes
- Rotation is free on every axis when a body is created.
- All three arguments are applied on every call: an axis passed
falseis released, not left alone. - Locking an axis clears the angular velocity around it, so a body that was already turning stops rather than keeping the rotation it had.
- The body can still be turned around a locked axis by hand through
natiny_entity_set_rotation. natiny_physics_set_fixed_rotationis the same call with one value for all three axes; either call overwrites what the other set.- Linear motion is unaffected.
- Passing a handle that is not a live body has no effect.