natiny.physics.set_velocity

Lua
natiny.physics.set_velocity(body, vx, vy, vz)

Sets a body's linear velocity in world space and wakes it.

Parameters

Name Type Description
body number Body handle
vx number Metres per second along X
vy number Metres per second along Y
vz number Metres per second along Z

Example

Lua
natiny.physics.set_velocity(player, 0, 5, 0)   -- jump

Notes

  • This replaces whatever the body was doing, which is what a jump or a conveyor wants and what a push does not - for a push, use natiny.physics.apply_impulse.
  • Wakes the body, so it is felt on the next step even if it had gone to sleep.
  • The way to drive a kinematic body that should carry others along with it.
  • Static bodies ignore velocity changes.