attachChild: Difference between revisions

From Bohemia Interactive Community
(Created page with "{{RV|type=command |game1= arma3 |version1= 2.22 |branch= dev |arg=local |eff=global |serverExec= |gr1= Object Manipulation |descr={{Wiki|WIP}} Attaches a child object to a parent, similar to attachTo but instead of a rigid/forced attachment its using a PhysX joint. {{Feature|informative|For more information see {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Joints.html|NVIDIA docs}}.}} {{Feature|informative|Does NOT beh...")
 
m (Some wiki formatting)
 
(7 intermediate revisions by 2 users not shown)
Line 6: Line 6:
|branch= dev
|branch= dev


|arg=local
|arg= local
 
|eff= global
|eff=global


|serverExec=
|serverExec=


|gr1= Object Manipulation
|gr1= PhysX


|descr={{Wiki|WIP}}  
|descr= Attaches a child object to a parent, similar to [[attachTo]] but instead of a rigid/forced attachment its using a PhysX joint.
{{Feature|informative|For more information see {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Joints.html|NVIDIA docs}}.}}
Note that the joint parameters XYZ orientations, are according to the localFrame of the joint. swingZ/swingY/twist being Yaw/Roll/Pitch, can be changed if the joint itself is rotated, because the joint rotation moves the whole axis.


Attaches a child object to a parent, similar to [[attachTo]] but instead of a rigid/forced attachment its using a PhysX joint.
{{Wiki|WIP}}
{{Feature|informative|For more information see {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Joints.html|NVIDIA docs}}.}}


{{Feature|informative|Does NOT behave well in Multiplayer!}}
|mp= {{Feature|important|This command does NOT behave well in Multiplayer.}}


|s1= [parent, child] [[attachChild]] [jointType, localFrameParent, localFrameChild, miscFlags, jointDescription]
|s1= [parent, child] [[attachChild]] [jointType, localFrameParent, localFrameChild, miscFlags, jointDescription]


|p1= parent: [[Object]] - The parent object that another object is attached to. Must be a Transport vehicle like Car/Tank (Maybe helicopter/airplane works?).
|p1= parent: [[Object]] - the parent object that another object is attached to. Must be a Transport vehicle like Car/Tank (Maybe helicopter/airplane works?).
 
|p2= child: [[Object]] - the object being attached onto the parent. Must be a Transport vehicle like Car/Tank (Maybe helicopter/airplane works?).


|p2= child: [[Object]] - The object being attached onto the parent. Must be a Transport vehicle like Car/Tank (Maybe helicopter/airplane works?).
|p3= jointType: [[String]] - currently only "6DOFJoint" and "RevoluteJoint" and "FixedJoint"<br>


|p3= jointType: [[String]] - Currently only "6DOFJoint" and "RevoluteJoint" and "FixedJoint"<br>
<div class="_description">
A 6DOFJoint allows to configure all axis (XYZ translation, Pitch/Yaw/Roll rotation) limits and drives.<br>
; 6DOFJoint
A RevoluteJoint only allows rotation around the X axis, a Revolute joint can also be implemented with a 6DOFJoint and the appropriate limits (internally it is implemented exactly like that)<br>
: Allows to configure all axis (XYZ translation, Pitch/Yaw/Roll rotation) limits and drives.
A FixedJoint is limited in all axis, it essentially works like a PhysX based attachTo.<br>
; RevoluteJoint
: Only allows rotation around the X axis, a Revolute joint can also be implemented with a 6DOFJoint and the appropriate limits (internally it is implemented exactly like that)
; FixedJoint
: Limited in all axis, it essentially works like a PhysX based attachTo.
</div>


|p4= localFrameParent: [[Array]] - The Position and orientation, in parent's model-space of where the joint will be placed.<br>
|p4= localFrameParent: [[Array]] - the Position and orientation, in parent's model-space of where the joint will be placed.<br>
An Array of 3 elements [position, upPos, dirPos]<br>
An Array of 3 elements [position, upPos, dirPos]<br>
Each element can either be a Vector (3-element array of [[Number]]) or a Memory point name ([[String]]).<br>
Each element can either be a Vector (3-element array of [[Number]]) or a Memory point name ([[String]]).<br>
Line 41: Line 47:
For example:
For example:
<sqf>
<sqf>
_jointPos = [0,0,0];
private _jointPos = [0, 0, 0];
_vectorDir = [0,1,0];
private _vectorDir = [0, 1, 0];
_vectorUp = [0,0,1];
private _vectorUp = [0, 0, 1];
[_jointPos, _jointPos vectorAdd _vectorDir, _jointPos vectorAdd _vectorUp];
[_jointPos, _jointPos vectorAdd _vectorDir, _jointPos vectorAdd _vectorUp];
</sqf>
</sqf>


|p5= localFrameChild: [[Array]] - The Position and orientation, in child's model-space of where the joint will be placed.
|p5= localFrameChild: [[Array]] - the position and orientation, in child's model-space of where the joint will be placed.


|p6= miscFlags: [[Array]] - [collisionEnabled (Default [[false]]), breakForce (Default -1)]
|p6= miscFlags: [[Array]] - [(collisionEnabled, breakForce)]


<div class="_description">
;
: collisionEnabled: [[Boolean]] (Optional, Default: [[false]]) - When false, disables collision between the two joint-ed objects
;
: breakForce: [[Number]] (Optional, Default: -1)
;
: limitsAreForces?
</div>


|p7= jointDescription: [[Array]] - This specifies the behavior/limits of the joint.<br>
|p7= jointDescription: [[Array]] - this specifies the behavior/limits of the joint.<br>
[(linearLimit, swingLimit, twistLimit, drives)] <br>
[(linearLimit, swingLimit, twistLimit, drives)] <br><br>Note that all are optional. Passing an empty array is equivalent to using a "FixedJoint" type<br>
<br>
Note that all are optional. Passing an empty array is equivalent to using a "FixedJoint" type<br>
<br>
linearLimit: [[Array]] - <br>
<br>
Linear limit specifies the joints permitted translation along the XYZ axis.<br>
There are three types of linear limits, fully locked, per-axis limit and distance limit.<br>
<br>
Fully Locked:<br>
[]<br>
Empty array, will completely lock the XYZ translational axes, only allowing rotational movement (If allowed in the swing/twist limits)<br>
<br>
Per axis:<br>
[limitX, limitY, limitZ]<br>
limit*: [[Array]] - [lowerLimit, upperLimit, springParameters]<br>
lowerLimit: [[Number]] - The minimum permitted offset on the axis<br>
upperLimit: [[Number]] - The maximum permitted offset on the axis<br>
upperLimit must be larger than lowerLimit<br>
springParameters: [[Array]] - [(restitution, spring, damping)]<br>
restitiution: [[Number]] (Optional, Default: 0) - Must be between 0-1.<br>
Controls the amount of bounce when the joint hits a limit.<br>
A restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit.<br>
A value of zero causes the joint to stop dead.<br>
{{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxJointLimitParameters.html#cf208a0f1e54fb8e9219af1e0357d4a9|NVIDIA docs}}<br>
spring: [[Number]] (Optional, Default: 0) - Must be 0 or greater.<br>
if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit <br>
damping: [[Number]] (Optional, Default: 0) - Must be 0 or greater. if spring is greater than zero, this is the damping of the limit spring <br>
<br>
All spring parameters are optional, but for the distance limits, atleast an empty array must be provided.<br>
<br>
Distance Limit:<br>
[xLocked, yLocked, zLocked, distanceLimit(, springParameters)]<br>
*Locked: [[Boolean]] - Whether the axis is completely locked and no translation is allowed along it<br>
distanceLimit: [[Number]] - Distance on meters, as a radius/sphere around the joint.<br>
<br>
<br>
swingLimit: [[Array]] - [(swingX, swingZ, springParameters)]<br>
All parameters are optional, the default is both swing axis being locked<br>
Swing limit comes in two types, cone and pyramid. Which variant is used depends on the datatype inside the swing parameter<br>
swingX is the rotation around the X (right) axis, thus the pitch.<br>
swingZ is the rotation around the Z (up) axis, thus the yaw.<br>
<br>
Cone limit:<br>
swing*: [[Number]] (Optional, Default 0/locked) - Rotation in radians, between [[pi]] and [[pi]]<br>
<br>
Pyramid limit:<br>
swing: [[Array]] - [(min, max)] - Same rotation in radians as the cone limit, but it can be asymetrical. Both are optional and default is 0/locked.<br>
<br>
<br>
Note that cone cannot be combined with pyramid, either both are cone or both are pyramid.<br>
<div class="_description">
If the swing limit is [[pi]], the rotation around that axis is fully unlocked/free.<br>
; linearLimit
<br>
: [[Array]] - Linear limit specifies the joints permitted translation along the XYZ axis.<br>There are three types of linear limits, fully locked, per-axis limit and distance limit.<br><br><div class="_description">
twistLimit: [[Array]] - [(twistLower, twistUpper, springParameters)]<br>
:; Fully Locked<nowiki>:</nowiki>
twist is rotation about the Y (front/dir) axis, thus the roll.<br>
:: []<br>Empty array, will completely lock the XYZ translational axes, only allowing rotational movement (If allowed in the swing/twist limits)
Left and right twist limits can be configured independently.<br>
:; Per axis<nowiki>:</nowiki>
<br>
:: [limitX, limitY, limitZ]<br><div class="_description">
twist*: [[Number]] (Optional, Default: 0) - Rotation limit in radians, between -2[[pi]] and 2[[pi]]<br>
::; limit*<nowiki>:</nowiki>
<br>
::: [[Array]] - [lowerLimit, upperLimit, springParameters] <div class="_description">
0 means twist is locked, and 2*pi means its completely unlocked<br>
:::; lowerLimit<nowiki>:</nowiki>
<br><br>
:::: [[Number]] - The minimum permitted offset on the axis
:::; upperLimit<nowiki>:</nowiki>
:::: [[Number]] - The maximum permitted offset on the axis<br> upperLimit must be larger than lowerLimit
:::; springParameters<nowiki>:</nowiki>
:::: [[Array]] - [(restitution, spring, damping)]<br>All spring parameters are optional, but for the linear limits, atleast an empty array must be provided. <div class="_description">
::::; restitiution<nowiki>:</nowiki>
::::: [[Number]] (Optional, Default: 0) - Must be between 0-1.<br> Controls the amount of bounce when the joint hits a limit.<br> A restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit.<br> A value of zero causes the joint to stop dead.<br> {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxJointLimitParameters.html#cf208a0f1e54fb8e9219af1e0357d4a9|NVIDIA docs}}
::::; spring<nowiki>:</nowiki>
::::: [[Number]] (Optional, Default: 0) - Must be 0 or greater.<br> if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
::::; damping<nowiki>:</nowiki>
::::: [[Number]] (Optional, Default: 0) - Must be 0 or greater. if spring is greater than zero, this is the damping of the limit spring</div>
::; Distance Limit
::: [xLocked, yLocked, zLocked, distanceLimit, springParameters]<br> <div class="_description">
:::; <nowiki>*</nowiki>Locked<nowiki>:</nowiki>
:::: [[Boolean]] - Whether the axis is completely locked and no translation is allowed along it
:::; distanceLimit<nowiki>:</nowiki>
:::: [[Number]] - Distance on meters, as a radius/sphere around the joint.
:; swingLimit<nowiki>:</nowiki>
:: [[Array]] - [(swingX, swingZ, springParameters)]<br>All parameters are optional, the default is both swing axis being locked<br>Swing limit comes in two types, cone and pyramid. Which variant is used depends on the datatype inside the swing parameter<br>Note that cone cannot be combined with pyramid, either both are cone or both are pyramid.<br>If the swing limit is [[pi]], the rotation around that axis is fully unlocked/free.<div class="_description">
::; Cone limit<nowiki>:</nowiki>
::: swingZ<nowiki>:</nowiki> [[Number]] (Optional, Default 0/locked) - The rotation around the Z (up) axis, thus the yaw. Rotation in radians, between [[pi]] and [[pi]].
::;
::: swingY<nowiki>:</nowiki> [[Number]] (Optional, Default 0/locked) - The rotation around the Y (front/dir) axis, thus the roll. Rotation in radians, between [[pi]] and [[pi]].
::; Pyramid limit<nowiki>:</nowiki>
::: swingZ<nowiki>:</nowiki> [[Array]] - [(min, max)] - Same rotation in radians as the cone limit, but it can be asymmetrical.
::;
::: swingY<nowiki>:</nowiki> [[Array]] - [(min, max)] - Same rotation in radians as the cone limit, but it can be asymmetrical.
:; twistLimit<nowiki>:</nowiki>
:: [[Array]] - [(twistLower, twistUpper, springParameters)]<br>Twist is rotation about the X (right) axis, thus the pitch.<br>Left and right twist limits can be configured independently.<br><div class="_description">
::; twist<nowiki>*:</nowiki>
::: [[Number]] (Optional, Default: 0) - Rotation limit in radians, between -2[[pi]] and 2[[pi]]<br> 0 means twist is locked, and 2*pi means its completely unlocked
:; drives<nowiki>:</nowiki>
:: [[Array]] - [(angularSwingDrive, angularTwistDrive, angularSlerpDrive, linearXDrive, linearYDrive, linearZDrive, limitsAreForces)]<br>Drives allow to apply force into the joint on any of the axes.<br>Each drive is a spring, one end being on the joint, and the other end being on the target specified by the commands:<br>[[setJointDrivePosition]] [[setJointDriveOrientation]] [[setJointDriveLinearVelocity]] [[setJointDriveAngularVelocity]]<br>For rotational drives there are two variants, Swing+Twist or SLERP (Spherical Linear Interpolation)<br>See {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Joints.html#drives|NVIDIA docs}}<div class="_description">
::; *Drive<nowiki>:</nowiki>
::: [[Array]] - [type, spring, damping, forceLimit]<div class="_description">
:::; type<nowiki>:</nowiki>
:::: [[Number]] - MUST be 0 (#TODO acceleration drive implementation?)<br>
:::; spring<nowiki>:</nowiki>
:::: [[Number]] - Same as springParameters above
:::; damping<nowiki>:</nowiki>
:::: [[Number]] - Same as springParameters above
:::; forceLimit<nowiki>:</nowiki>
::::  [[Number]] - The maximum force this drive c an apply to the joint
:; limitsAreForces<nowiki>:</nowiki>
:: [[Boolean]] (Optional, Default: true) - NOT IMPLEMENTED #TODO?</div>


drives: [[Array]] - [(angularTwistDrive, angularSwingDrive, angularSlerpDrive, linearXDrive, linearYDrive, linearZDrive, limitsAreForces)]<br>
|r1= [[Nothing]] - Do NOT depend on this staying nothing, it might change to be something.
Drives allow to apply force into the joint on any of the axes.<br>
Each drive is a spring, one end being on the joint, and the other end being on the target specified by the commands:<br>
[[setJointDrivePosition]] [[setJointDriveOrientation]] [[setJointDriveLinearVelocity]] [[setJointDriveAngularVelocity]]<br>


For rotational drives there are two variants, Swing+Twist or SLERP (Spherical Linear Interpolation)<br>
|x1= Attach a Quad (varname towbar) to a HEMTT (varName vParent) and another HEMTT (varName vChild) to the Quad.
See https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/Joints.html#drives<br>
Essentially using the Quad as a "towbar":
<br>
*Drive: [[Array]] - [type, spring, damping, forceLimit]<br>
<br>
type: [[Number]] - MUST be 0 (#TODO acceleration drive implementation?)<br>
spring: [[Number]] - Same as springParameters above<br>
damping: [[Number]] - Same as springParameters above<br>
forceLimit: [[Number]] - The maximum force this drive c an apply to the joint<br>
<br>
limitsAreForces: [[Boolean]] (Optional, Default: true) - NOT IMPLEMENTED #TODO?<br>
 
|x1=
Attach a Quad (varname towbar) to a HEMTT (varName vParent) and another HEMTT (varName vChild) to the Quad.
Essentially using the Quad as a "towbar"
<sqf>
<sqf>
_parentPos = [0,-5,0]; // position on the hemtt
_parentPos = [0, -5, 0]; // position on the hemtt
_childPos = [0,1,-0.2]; // position on the quad
_childPos = [0, 1, -0.2]; // position on the quad


_jointDescription =  
_jointDescription =
[
[
// Limits
// Limits
// Linear
// Linear
[], // Default is locked
[], // Default is locked


// Swing
// Swing
// [swing1 pitch, swing2 yaw, springParams]
// [swing1 yaw, swing2 roll, springParams]
[
[
rad 20, // pitch
rad 45, // yaw
rad 45 // yaw
0 // roll
],
],
// Twist Roll
// Twist pitch
// [twistLower, twistUpper, springParams]
// [twistLower, twistUpper, springParams]
[], // Default is locked
[rad -20, rad 20], // Default is locked
// Drives
 
// Drives
[] // Default are none
[] // Default are none
];
];


_params = [
_params = [
"6DOFJoint",  
"6DOFJoint",
// From [pos,dir,up]  
// From [pos,dir,up]
[_parentPos, _parentPos vectorAdd [0, 1, 0], _parentPos vectorAdd [0, 0, 1]],  
[_parentPos, _parentPos vectorAdd [0, 1, 0], _parentPos vectorAdd [0, 0, 1]],
// To [pos,dir,up]  
// To [pos,dir,up]
[_childPos, _childPos vectorAdd [0, 1, 0], _childPos vectorAdd [0, 0, 1]],  
[_childPos, _childPos vectorAdd [0, 1, 0], _childPos vectorAdd [0, 0, 1]],
// misc [collisions enabled]  
// misc [collisions enabled]
[false],  
[false],
_jointDescription
_jointDescription
];  
];
 
[vParent, towBar] attachChild _params;
[vParent, towBar] attachChild _params;
 
_parentPos = [0,-1,-0.2]; // Position on the quad
_parentPos = [0, -1, -0.2]; // Position on the quad
_childPos = [0,5,0]; // Position on the hemtt
_childPos = [0, 5, 0]; // Position on the hemtt


_params = [
_params = [
"6DOFJoint",  
"6DOFJoint",
// From [pos,dir,up]  
// From [pos,dir,up]
[_parentPos, _parentPos vectorAdd [0, 1, 0], _parentPos vectorAdd[0, 0, 1]],  
[_parentPos, _parentPos vectorAdd [0, 1, 0], _parentPos vectorAdd[0, 0, 1]],
// To [pos,dir,up]  
// To [pos,dir,up]
[_childPos, _childPos vectorAdd [0, 1, 0], _childPos vectorAdd [0, 0, 1]],  
[_childPos, _childPos vectorAdd [0, 1, 0], _childPos vectorAdd [0, 0, 1]],
// misc [collisions enabled]  
// misc [collisions enabled]
[false],  
[false],
_jointDescription
_jointDescription
];  
];


[towBar, vChild] attachChild _params;  
[towBar, vChild] attachChild _params;
</sqf>


</sqf>
|x2= Attach a Quad (varname towbar) to a HEMTT (varName vParent) and another HEMTT (varName vChild) to the Quad.
But we rotate the axis so that Swing's are Pitch/Yaw and Twist is roll
<sqf>
_parentPos = [0, -5, 0]; // position on the hemtt
_childPos = [0, 1, -0.2]; // position on the quad
 
_jointDescription =
[
// Limits
// Linear
[], // Default is locked
 
// Swing
// [swing1 pitch, swing2 yaw, springParams]
[
rad 20, // pitch
rad 45 // yaw
],
// Twist roll
// [twistLower, twistUpper, springParams]
[], // Default is locked
 
// Drives
[] // Default are none
];
 
_params = [
"6DOFJoint",
// From [pos,dir,up]
[_parentPos, _parentPos vectorAdd [0, 0, 1], _parentPos vectorAdd [1, 0, 0]], // Note how the up is pointing right and forward is pointing down, we are rotating the whole joint
// To [pos,dir,up]
[_childPos, _childPos vectorAdd [0, 0, 1], _childPos vectorAdd [1, 0, 0]],
// misc [collisions enabled]
[false],
_jointDescription
];


|x2= <sqf></sqf>
[vParent, towBar] attachChild _params;


|x3= <sqf></sqf>
_parentPos = [0, -1, -0.2]; // Position on the quad
_childPos = [0, 5, 0]; // Position on the hemtt


|x4= <sqf></sqf>
_params = [
"6DOFJoint",
// From [pos,dir,up]
[_parentPos, _parentPos vectorAdd [0, 0, 1], _parentPos vectorAdd [1, 0, 0]],
// To [pos,dir,up]
[_childPos, _childPos vectorAdd [0, 0, 1], _childPos vectorAdd [1, 0, 0]],
// misc [collisions enabled]
[false],
_jointDescription
];
 
[towBar, vChild] attachChild _params;
</sqf>


|x5= <sqf></sqf>


|seealso= [[detachChild]] [[setJointDrivePosition]] [[setJointDriveOrientation]] [[setJointDriveLinearVelocity]] [[setJointDriveAngularVelocity]]
|seealso= [[detachChild]] [[setJointDrivePosition]] [[setJointDriveOrientation]] [[setJointDriveLinearVelocity]] [[setJointDriveAngularVelocity]] [[childAttached]] [[parentAttached]]
}}
}}

Latest revision as of 01:21, 22 February 2026

Hover & click on the images for description
Only available in Development branch(es) until its release with Arma 3 patch v2.22.

Description

Description:
Attaches a child object to a parent, similar to attachTo but instead of a rigid/forced attachment its using a PhysX joint.
For more information see NVIDIA docs.

Note that the joint parameters XYZ orientations, are according to the localFrame of the joint. swingZ/swingY/twist being Yaw/Roll/Pitch, can be changed if the joint itself is rotated, because the joint rotation moves the whole axis.

🏗
This article is a work in progress!
Multiplayer:
This command does NOT behave well in Multiplayer.
Groups:
PhysX

Syntax

Syntax:
[parent, child] attachChild [jointType, localFrameParent, localFrameChild, miscFlags, jointDescription]
Parameters:
parent: Object - the parent object that another object is attached to. Must be a Transport vehicle like Car/Tank (Maybe helicopter/airplane works?).
child: Object - the object being attached onto the parent. Must be a Transport vehicle like Car/Tank (Maybe helicopter/airplane works?).
jointType: String - currently only "6DOFJoint" and "RevoluteJoint" and "FixedJoint"
6DOFJoint
Allows to configure all axis (XYZ translation, Pitch/Yaw/Roll rotation) limits and drives.
RevoluteJoint
Only allows rotation around the X axis, a Revolute joint can also be implemented with a 6DOFJoint and the appropriate limits (internally it is implemented exactly like that)
FixedJoint
Limited in all axis, it essentially works like a PhysX based attachTo.
localFrameParent: Array - the Position and orientation, in parent's model-space of where the joint will be placed.
An Array of 3 elements [position, upPos, dirPos]
Each element can either be a Vector (3-element array of Number) or a Memory point name (String).


An important Caveat when using Vectors is that dir and up are not direction vectors, but positions.
Essentially, upPos/dirPos would be the model-space coordinates of where the memory point would be.
For example:
private _jointPos = [0, 0, 0]; private _vectorDir = [0, 1, 0]; private _vectorUp = [0, 0, 1]; [_jointPos, _jointPos vectorAdd _vectorDir, _jointPos vectorAdd _vectorUp];
localFrameChild: Array - the position and orientation, in child's model-space of where the joint will be placed.
miscFlags: Array - [(collisionEnabled, breakForce)]
collisionEnabled: Boolean (Optional, Default: false) - When false, disables collision between the two joint-ed objects
breakForce: Number (Optional, Default: -1)
limitsAreForces?
jointDescription: Array - this specifies the behavior/limits of the joint.
[(linearLimit, swingLimit, twistLimit, drives)]

Note that all are optional. Passing an empty array is equivalent to using a "FixedJoint" type

linearLimit
Array - Linear limit specifies the joints permitted translation along the XYZ axis.
There are three types of linear limits, fully locked, per-axis limit and distance limit.

Fully Locked:
[]
Empty array, will completely lock the XYZ translational axes, only allowing rotational movement (If allowed in the swing/twist limits)
Per axis:
[limitX, limitY, limitZ]
limit*:
Array - [lowerLimit, upperLimit, springParameters]
lowerLimit:
Number - The minimum permitted offset on the axis
upperLimit:
Number - The maximum permitted offset on the axis
upperLimit must be larger than lowerLimit
springParameters:
Array - [(restitution, spring, damping)]
All spring parameters are optional, but for the linear limits, atleast an empty array must be provided.
restitiution:
Number (Optional, Default: 0) - Must be between 0-1.
Controls the amount of bounce when the joint hits a limit.
A restitution value of 1.0 causes the joint to bounce back with the velocity which it hit the limit.
A value of zero causes the joint to stop dead.
NVIDIA docs
spring:
Number (Optional, Default: 0) - Must be 0 or greater.
if greater than zero, the limit is soft, i.e. a spring pulls the joint back to the limit
damping:
Number (Optional, Default: 0) - Must be 0 or greater. if spring is greater than zero, this is the damping of the limit spring
Distance Limit
[xLocked, yLocked, zLocked, distanceLimit, springParameters]
*Locked:
Boolean - Whether the axis is completely locked and no translation is allowed along it
distanceLimit:
Number - Distance on meters, as a radius/sphere around the joint.
swingLimit:
Array - [(swingX, swingZ, springParameters)]
All parameters are optional, the default is both swing axis being locked
Swing limit comes in two types, cone and pyramid. Which variant is used depends on the datatype inside the swing parameter
Note that cone cannot be combined with pyramid, either both are cone or both are pyramid.
If the swing limit is pi, the rotation around that axis is fully unlocked/free.
Cone limit:
swingZ: Number (Optional, Default 0/locked) - The rotation around the Z (up) axis, thus the yaw. Rotation in radians, between pi and pi.
swingY: Number (Optional, Default 0/locked) - The rotation around the Y (front/dir) axis, thus the roll. Rotation in radians, between pi and pi.
Pyramid limit:
swingZ: Array - [(min, max)] - Same rotation in radians as the cone limit, but it can be asymmetrical.
swingY: Array - [(min, max)] - Same rotation in radians as the cone limit, but it can be asymmetrical.
twistLimit:
Array - [(twistLower, twistUpper, springParameters)]
Twist is rotation about the X (right) axis, thus the pitch.
Left and right twist limits can be configured independently.
twist*:
Number (Optional, Default: 0) - Rotation limit in radians, between -2pi and 2pi
0 means twist is locked, and 2*pi means its completely unlocked
drives:
Array - [(angularSwingDrive, angularTwistDrive, angularSlerpDrive, linearXDrive, linearYDrive, linearZDrive, limitsAreForces)]
Drives allow to apply force into the joint on any of the axes.
Each drive is a spring, one end being on the joint, and the other end being on the target specified by the commands:
setJointDrivePosition setJointDriveOrientation setJointDriveLinearVelocity setJointDriveAngularVelocity
For rotational drives there are two variants, Swing+Twist or SLERP (Spherical Linear Interpolation)
See NVIDIA docs
*Drive:
Array - [type, spring, damping, forceLimit]
type:
Number - MUST be 0 (#TODO acceleration drive implementation?)
spring:
Number - Same as springParameters above
damping:
Number - Same as springParameters above
forceLimit:
Number - The maximum force this drive c an apply to the joint
limitsAreForces:
Boolean (Optional, Default: true) - NOT IMPLEMENTED #TODO?
Return Value:
Nothing - Do NOT depend on this staying nothing, it might change to be something.

Examples

Example 1:
Attach a Quad (varname towbar) to a HEMTT (varName vParent) and another HEMTT (varName vChild) to the Quad. Essentially using the Quad as a "towbar":
_parentPos = [0, -5, 0]; // position on the hemtt _childPos = [0, 1, -0.2]; // position on the quad _jointDescription = [ // Limits // Linear [], // Default is locked // Swing // [swing1 yaw, swing2 roll, springParams] [ rad 45, // yaw 0 // roll ], // Twist pitch // [twistLower, twistUpper, springParams] [rad -20, rad 20], // Default is locked // Drives [] // Default are none ]; _params = [ "6DOFJoint", // From [pos,dir,up] [_parentPos, _parentPos vectorAdd [0, 1, 0], _parentPos vectorAdd [0, 0, 1]], // To [pos,dir,up] [_childPos, _childPos vectorAdd [0, 1, 0], _childPos vectorAdd [0, 0, 1]], // misc [collisions enabled] [false], _jointDescription ]; [vParent, towBar] attachChild _params; _parentPos = [0, -1, -0.2]; // Position on the quad _childPos = [0, 5, 0]; // Position on the hemtt _params = [ "6DOFJoint", // From [pos,dir,up] [_parentPos, _parentPos vectorAdd [0, 1, 0], _parentPos vectorAdd[0, 0, 1]], // To [pos,dir,up] [_childPos, _childPos vectorAdd [0, 1, 0], _childPos vectorAdd [0, 0, 1]], // misc [collisions enabled] [false], _jointDescription ]; [towBar, vChild] attachChild _params;
Example 2:
Attach a Quad (varname towbar) to a HEMTT (varName vParent) and another HEMTT (varName vChild) to the Quad. But we rotate the axis so that Swing's are Pitch/Yaw and Twist is roll
_parentPos = [0, -5, 0]; // position on the hemtt _childPos = [0, 1, -0.2]; // position on the quad _jointDescription = [ // Limits // Linear [], // Default is locked // Swing // [swing1 pitch, swing2 yaw, springParams] [ rad 20, // pitch rad 45 // yaw ], // Twist roll // [twistLower, twistUpper, springParams] [], // Default is locked // Drives [] // Default are none ]; _params = [ "6DOFJoint", // From [pos,dir,up] [_parentPos, _parentPos vectorAdd [0, 0, 1], _parentPos vectorAdd [1, 0, 0]], // Note how the up is pointing right and forward is pointing down, we are rotating the whole joint // To [pos,dir,up] [_childPos, _childPos vectorAdd [0, 0, 1], _childPos vectorAdd [1, 0, 0]], // misc [collisions enabled] [false], _jointDescription ]; [vParent, towBar] attachChild _params; _parentPos = [0, -1, -0.2]; // Position on the quad _childPos = [0, 5, 0]; // Position on the hemtt _params = [ "6DOFJoint", // From [pos,dir,up] [_parentPos, _parentPos vectorAdd [0, 0, 1], _parentPos vectorAdd [1, 0, 0]], // To [pos,dir,up] [_childPos, _childPos vectorAdd [0, 0, 1], _childPos vectorAdd [1, 0, 0]], // misc [collisions enabled] [false], _jointDescription ]; [towBar, vChild] attachChild _params;

Additional Information

See also:
detachChild setJointDrivePosition setJointDriveOrientation setJointDriveLinearVelocity setJointDriveAngularVelocity childAttached parentAttached

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord.
Only post proven facts here! Add Note