Difference between revisions of "R3d.World:createBallAndSocketJoint"

From GiderosMobile
 
(3 intermediate revisions by 2 users not shown)
Line 3: Line 3:
  
 
=== Description ===
 
=== Description ===
Creates a ball and socket joint. See its [[R3d.BallAndSocketJoint|definition]].
+
Creates a ball and socket joint.
 +
<syntaxhighlight lang="lua">
 +
r3d.World:createBallAndSocketJoint(bodyA,bodyB,anchorX,anchorY,anchorZ,params)
 +
</syntaxhighlight>
  
Possible params are:
+
The BallAndSocketJoint class describes a ball and socket joint between two bodies.
* '''isCollisionEnabled''' (bool)
+
 
<source lang="lua">
+
In a ball and socket joint, the two bodies cannot translate with respect to each other. However, they can rotate freely around a common anchor point. This joint has three degrees of freedom and can be used to simulate a chain of bodies for instance.
r3d.World:createBallAndSocketJoint(bodyA,bodyB,anchorX,anchorY,anchorZ,params)
+
 
</source>
+
You need to provide the pointers to the two rigid bodies and also the coordinates of the anchor point (in world-space). At the joint creation, the world-space anchor point will be converted into the local-space of the two rigid bodies and then, the joint will make sure that the two local-space anchor points match in world-space. Therefore, the two bodies need to be in a correct position at the joint creation.
 +
 
 +
'''Note''' this method will also return a pointer to the BallAndSocketJoint object that has been created internally. You will then be able to use that pointer to change properties of the joint and also to destroy it at the end
  
 
=== Parameters ===
 
=== Parameters ===
Line 17: Line 22:
 
'''anchorY''': (number) anchor y<br/>
 
'''anchorY''': (number) anchor y<br/>
 
'''anchorZ''': (number) anchor z<br/>
 
'''anchorZ''': (number) anchor z<br/>
'''params''': (table) the params table<br/>
+
'''params''': (table) '''optional''' any of the followings:
 +
*''isCollisionEnabled'' (bool)
  
 
=== Example ===
 
=== Example ===
<source lang="lua">
+
<syntaxhighlight lang="lua">
world:createBallAndSocketJoint(cube01body, cube02body, 0, 0, 0, {isCollisionEnabled=false})
+
local basj = world:createBallAndSocketJoint(cube01body, cube02body, 0, 0, 0, {isCollisionEnabled=false})
</source>
+
</syntaxhighlight>
  
 
{{R3d.World}}
 
{{R3d.World}}

Latest revision as of 07:52, 18 December 2025

Available since: Gideros 2019.10
Class: R3d.World

Description

Creates a ball and socket joint.

r3d.World:createBallAndSocketJoint(bodyA,bodyB,anchorX,anchorY,anchorZ,params)

The BallAndSocketJoint class describes a ball and socket joint between two bodies.

In a ball and socket joint, the two bodies cannot translate with respect to each other. However, they can rotate freely around a common anchor point. This joint has three degrees of freedom and can be used to simulate a chain of bodies for instance.

You need to provide the pointers to the two rigid bodies and also the coordinates of the anchor point (in world-space). At the joint creation, the world-space anchor point will be converted into the local-space of the two rigid bodies and then, the joint will make sure that the two local-space anchor points match in world-space. Therefore, the two bodies need to be in a correct position at the joint creation.

Note this method will also return a pointer to the BallAndSocketJoint object that has been created internally. You will then be able to use that pointer to change properties of the joint and also to destroy it at the end

Parameters

bodyA: (b3d body) body A
bodyB: (b3d body) body B
anchorX: (number) anchor x
anchorY: (number) anchor y
anchorZ: (number) anchor z
params: (table) optional any of the followings:

  • isCollisionEnabled (bool)

Example

local basj = world:createBallAndSocketJoint(cube01body, cube02body, 0, 0, 0, {isCollisionEnabled=false})