PhysicsSetChildShapeOffsets

From Multi Theft Auto: Wiki
Revision as of 19:45, 12 February 2020 by CrosRoad95 (talk | contribs) (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=...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Sets offset position and/or rotation of child shape.

Causes all rigids which uses this shape got activated.

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