natiny.physics.init

Lua
natiny.physics.init() -> ok

Creates the rigid-body world and starts stepping it once per frame.

Returns

Type Description
boolean true when the world was created, otherwise false

Example

Lua
local ok = natiny.physics.init()

Notes

  • Call this after natiny.backend.init, because backend initialization resets all engine state, including the physics world. Repeated calls do nothing and return true.
  • Until initialization succeeds, mutation calls do nothing, raycast returns nil, get_velocity returns zeroes, and body constructors raise an error.
  • Units are metres, kilograms and seconds. Gravity starts at 9.81 m/s downwards along -Y; change it with natiny.physics.set_gravity.
  • The world advances in fixed 1/60 s ticks. At most 0.25 s of elapsed time is accumulated per frame.
  • Physics steps before the frame callback.