PhysicsAddChildShape: Difference between revisions
Jump to navigation
Jump to search
CrosRoad95 (talk | contribs) (Created page with "__NOTOC__ {{Client function}} Adds child shape to already existing, compound shape. Limit: 8196 child shapes. ==Syntax== <syntaxhighlight lang="lua"> boolean physicsAddShap...") |
CrosRoad95 (talk | contribs) No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
==Syntax== | ==Syntax== | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
boolean | boolean physicsAddChildShape(physics-shape compoundShape, physics-shape childShape [, float offsetX, float offsetY, float offsetZ [, float offsetRotationX, float offsetRotationY, float offsetRotationZ] ] ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 21: | Line 21: | ||
Creates something that reminds chain | Creates something that reminds chain | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
local compound = physicsCreateShape(physics, "compound") | |||
local capsule = physicsCreateShape(physics, "capsule", 0.2,1.5) | |||
physicsAddChildShape(compound, capsule) | |||
physicsAddChildShape(compound, capsule, 0,1,0.5, 45,0,0) | |||
physicsAddChildShape(compound, capsule, 0,1,0.5, 45,0,0) | |||
physicsAddChildShape(compound, capsule, 0,-1,0.5, -45,0,0) | |||
physicsAddChildShape(compound, capsule, 0,-0.8,1.5, 120,0,0) | |||
physicsAddChildShape(compound, capsule, 0,0.8,1.5, -120,0,0) | |||
function createChainLink(x,y,z,rx,ry,rz) | |||
local link = physicsCreateRigidBody(physics,compound) | local link = physicsCreateRigidBody(physics,compound) | ||
physicsSetProperties(link, "position", x,y,z) | physicsSetProperties(link, "position", x,y,z) | ||
Line 35: | Line 37: | ||
end | end | ||
function createChain() | |||
for i=1,2 do | for i=1,2 do | ||
createChainLink(0,0,5 + i,0,0,0) | createChainLink(0,0,5 + i,0,0,0) | ||
Line 41: | Line 43: | ||
end | end | ||
end | end | ||
createChain() | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Latest revision as of 14:37, 12 February 2020
Adds child shape to already existing, compound shape. Limit: 8196 child shapes.
Syntax
boolean physicsAddChildShape(physics-shape compoundShape, physics-shape childShape [, float offsetX, float offsetY, float offsetZ [, float offsetRotationX, float offsetRotationY, float offsetRotationZ] ] )
Required Arguments
- compoundShape: Must be compound shape
- childShape: Can not be compound shape
- offsetXYZ: Offset position of center
- rotationXYZ: Offset rotationof center
Returns
True, if shape got added. False otherwise.
Example
Creates something that reminds chain
local compound = physicsCreateShape(physics, "compound") local capsule = physicsCreateShape(physics, "capsule", 0.2,1.5) physicsAddChildShape(compound, capsule) physicsAddChildShape(compound, capsule, 0,1,0.5, 45,0,0) physicsAddChildShape(compound, capsule, 0,1,0.5, 45,0,0) physicsAddChildShape(compound, capsule, 0,-1,0.5, -45,0,0) physicsAddChildShape(compound, capsule, 0,-0.8,1.5, 120,0,0) physicsAddChildShape(compound, capsule, 0,0.8,1.5, -120,0,0) function createChainLink(x,y,z,rx,ry,rz) local link = physicsCreateRigidBody(physics,compound) physicsSetProperties(link, "position", x,y,z) physicsSetProperties(link, "rotation", rx,ry,rz) end function createChain() for i=1,2 do createChainLink(0,0,5 + i,0,0,0) createChainLink(0,0,6 + i,0,0,90) end end createChain()
See Also
- physicsCreateWorld
- physicsDestroy
- physicsCreateShape
- physicsCreateShapeFromModel
- physicsCreateRigidBody
- physicsCreateStaticCollision
- physicsCreateConstraint
- physicsAddChildShape
- physicsRemoveChildShape
- physicsGetChildShapes
- physicsSetChildShapeOffsets
- physicsGetChildShapeOffsets
- physicsGetShapes
- physicsGetRigidBodies
- physicsGetStaticCollisions
- physicsGetConstraints
- physicsSetProperties
- physicsGetProperties
- physicsDrawDebug
- physicsSetDebugMode
- physicsBuildCollisionFromGTA
- physicsApplyVelocity
- physicsApplyVelocityForce
- physicsApplyAngularVelocity
- physicsApplyAngularVelocityForce
- physicsApplyDamping
- physicsRayCast
- physicsShapeCast
- physicsGetElementType
- physicsIsElement