PhysicsSetChildShapeOffsets: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ {{Client function}} Sets offset position and/or rotation of child shape. Causes all rigids which uses this shape got activated. ==Syntax== <syntaxhighlight lang=...")
 
No edit summary
 
Line 4: Line 4:


Causes all rigids which uses this shape got activated.
Causes all rigids which uses this shape got activated.
Keeps last position/rotation if newly set position/rotation is equal 0


==Syntax==  
==Syntax==  

Latest revision as of 20:07, 12 February 2020

Sets offset position and/or rotation of child shape.

Causes all rigids which uses this shape got activated. Keeps last position/rotation if newly set position/rotation is equal 0

Syntax

bool physicsSetChildShapeOffsets(physics-shape compoundShape, int index, float x, float y, float z [, float rx, float ry, float rz ] )

Required Arguments

  • compoundShape: Must be compound shape
  • index: Index of child. Starts from 1.
  • xyz: Offset position
  • rx, ry, rz: Offset rotation

Returns

Returns true if offset got changed, false otherwise

Example

local compound = physicsCreateShape(physics, "compound")
local box = physicsCreateShape(physics, "box", 1)
physicsAddChildShape(compound, box,0,0,0,0,0,0)
physicsAddChildShape(compound, box,0,0,0,0,0,0)
physicsAddChildShape(compound, box,0,0,0,0,0,0)
local c = physicsCreateRigidBody(physics,compound)
physicsSetProperties(c, "position", 0,0,20)
addEventHandler("onClientPreRender", root, function()
  physicsSetChildShapeOffsets(compound,1, 0,2,math.cos(getTickCount()/500))
  physicsSetChildShapeOffsets(compound,3, 0,-2,math.cos(getTickCount()/500))
end)

See Also