PhysicsCreateRigidBody

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

Creates rigid body from shape

Syntax

physics-rigid-body physicsCreateRigidBody( physics-shape theShape [ , float mass, float localInertiaX, float localInertiaY, float localInertiaZ, float centerOfMassX, float centerOfMassY, float centerOfMassZ ])

Required Arguments

  • theShape : the shape of rigid body
  • mass: mass of rigid body, by default 1, must be greater than 0
  • localInertiaXYZ: local inertia
  • centerOfMassYYZ: center of mass

Returns

Rigid body, false otherwise.

Example

Crushing 27 boxes

local box = physicsCreateShape(physics, "box", 1)
local sphere = physicsCreateShape(physics, "sphere", 3)
local function crush()
  for x = 1,3 do
    for y = 1,3 do
      for z = 1,3 do
        local boxrb = physicsCreateRigidBody(box)
        physicsSetProperties(boxrb, "position", x*2,y*2,3 + z * 2)
      end
    end
  end
    
  local sphereOfDoom = physicsCreateRigidBody(sphere, 10000)
  physicsSetProperties(sphereOfDoom, "position", 3,3,50)
end
crush()

See Also