PhysicsSetChildShapeOffsets

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

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