PhysicsCreateRigidBody: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} Creates rigid body from shape ==Syntax== <syntaxhighlight lang="lua"> physics-rigid-body physicsCreateRigidBody( physics-shape theShape [ , fl...")
 
No edit summary
 
Line 5: Line 5:
==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
physics-rigid-body physicsCreateRigidBody( physics-shape theShape [ , float mass, float localInertiaX, float localInertiaY, float localInertiaZ, float centerOfMassX, float centerOfMassY, float centerOfMassZ ])            
physics-rigid-body physicsCreateRigidBody( physics-shape theShape [ , float mass, float localInertiaX, float localInertiaY, float localInertiaZ, float centerOfMassX, float centerOfMassY, float centerOfMassZ ])</syntaxhighlight>  
</syntaxhighlight>  


===Required Arguments===  
===Required Arguments===  

Latest revision as of 16:21, 14 February 2020

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