PhysicsApplyVelocity

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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