natiny.physics.set_fixed_rotation

Lua
natiny.physics.set_fixed_rotation(body, enabled)

Locks or unlocks rotation of a body around all three axes at once. A locked body keeps the orientation it has and cannot be turned by gravity, contacts or impulses.

Parameters

Name Type Description
body number Body handle
enabled boolean true to lock all three rotation axes; false to release them

Example

Lua
local player = natiny.physics.cylinder(0.4, 1.8)
natiny.physics.set_fixed_rotation(player, true)

Notes

  • Rotation is free when a body is created.
  • Locking clears the angular velocity around every locked axis, so a body that was already toppling stops where it stands rather than keeping the tilt.
  • The body can still be turned by hand through natiny.entity.set_rotation, which is how an upright character aims.
  • This is natiny.physics.set_rotation_locks with the same value on 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.