PhysicsApplyVelocity

From Multi Theft Auto: Wiki
Jump to navigation Jump to search

Applies velocity to rigid body

Syntax

bool physicsApplyVelocity( physics-rigid-body theRigidBody, float velocityX, float velocityY, float velocityZ [, float relativeX, float relativeY, float relativeZ ] )             

Required Arguments

  • theRigidBody: rigid body you want to apply velocity
  • velocityXYZ: velocity you wants to apply
  • relativeXYZ: relative position, default: 0,0,0

Returns

True if velocity got applied, false otherwise.

Example

Doing box flip

local box = physicsCreateShape(physics, "box", 1)
local function spawnTestBox(x,y,z)
  local boxrb = physicsCreateRigidBody(box)
  physicsSetProperties(boxrb, "position", x,y,z)
  return boxrb;
end

local notATable = spawnTestBox(0,0,5)
setTimer(function()
  physicsApplyVelocity(notATable , 0,0,10, 0,1,0)
end,500,1) -- let box land on the ground.

See Also