addTorque: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Bot: Reverted to revision 103586 by SimZor on 2017-06-22T19:40:23Z)
m (Text replacement - "[[Image:" to "[[File:")
 
(42 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|=
{{RV|type=command
____________________________________________________________________________________________
|game1= arma3
|arma3 |= Game
|version1= 1.72
|1.72|= Game Version
|arg= global
|arg= global |= Multiplayer Arguments
|eff= global
|eff= global |= Multiplayer Effects
 
____________________________________________________________________________________________
|gr1= Object Manipulation
|Applies torque (rotation momentum) to the [[getCenterOfMass | center of mass]] of the given object. Torque force is defined as vector [x, y, z] applied in world space. If you need to define torque in model space, convert the torque vector first by [[vectorModelToWorld]] or [[vectorModelToWorldVisual]] command. The torque applied as impulse. Diagram below explain which way the object would rotate.  For more information see [http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxRigidBody.html#acb04ffc816d45afff2d04e93d7446e79 NVIDIA docs] <br>
 
[[Image:addTorque.jpg|400px]]|= Description
|descr= [[File:addTorque_correct.jpg|400px|right]]
____________________________________________________________________________________________
Applies torque (rotation momentum) to the [[getCenterOfMass | center of mass]] of the given object. Torque force is defined as vector [x, y, z] applied in world space. If you need to define torque in model space, convert the torque vector first by [[vectorModelToWorld]] or [[vectorModelToWorldVisual]] command. The torque applied as impulse. Diagram below explain which way the object would rotate.  For more information see {{Link|http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxRigidBody.html#acb04ffc816d45afff2d04e93d7446e79|NVIDIA docs}} <br>
| object '''addTorque''' torque |= Syntax
 
|p1= object: [[Object]] - PhysX object|= Parameter 1
{{Feature|informative|
|p2= torque: [[Array]] - world vector in format [x,y,z]  |= Parameter 2
A single application of torque would produce one impulse, which may not be enough. In this case consider applying a series of continuous impulses, for example to make a quad bike to roll forward:
|p3=  |= Parameter 3
<sqf>onEachFrame { quad addTorque (quad vectorModelToWorld [100,0,0]) };</sqf>
|p4=  |= Parameter 4
|p5=  |= Parameter 5
|p6=  |= Parameter 6
| [[Nothing]] |= Return Value
|x1= Apply torque [1000,0,0] to object not factoring object positioning:
<code>_wheel [[addTorque]] [1000,0,0];</code>|= Example 1
|x2= Apply torque [1000,0,0] relative to object:
<code>_wheel [[addTorque]] (_wheel [[vectorModelToWorld]] [1000,0,0]);</code>|= Example 2
|[[addForce]], [[vectorModelToWorld]], [[vectorModelToWorldVisual]] |= See Also
}}
}}
{{Feature|important|This command doesn't follow convention for torque direction, which obeys right-hand rule. To comply, negate all values in the vector.}}
|s1= object [[addTorque]] torque
|p1= object: [[Object]] - PhysX object
|p2= torque: [[Array]] - world vector in format [x,y,z]
|r1= [[Nothing]]


<dl class='command_description'>
|x1= Apply torque [1000,0,0] to object not factoring object positioning:
<!-- BEGIN Note Section -->
<sqf>_wheel addTorque [1000,0,0];</sqf>
<!-- For example:
<dd class='notedate'>Posted on Month Day, Year - Time (UTC)</dd>
<dt class='note'>'''[[User:User Name|User Name]]'''</dt>
<dd class='note'>This is an example note. It is true and verifiable, and contains a little code snippet.
<code>[[if]] ([[_this]] == anExample) [[then]] { [[hint]] Leave it here for others to read; };</code></dd>
-->
<!-- END Note Section -->
</dl>


<h3 style='display:none'>Bottom Section</h3>
|x2= Apply torque [1000,0,0] relative to object:
<!-- Appropriate categories go here -->
<sqf>_wheel addTorque (_wheel vectorModelToWorld [1000,0,0]);</sqf>


[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
|seealso= [[addForce]] [[awake]] [[isAwake]] [[vectorModelToWorld]] [[vectorModelToWorldVisual]] [[disableBrakes]] [[brakesDisabled]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
}}

Latest revision as of 00:10, 21 November 2023

Hover & click on the images for description

Description

Description:
addTorque correct.jpg

Applies torque (rotation momentum) to the center of mass of the given object. Torque force is defined as vector [x, y, z] applied in world space. If you need to define torque in model space, convert the torque vector first by vectorModelToWorld or vectorModelToWorldVisual command. The torque applied as impulse. Diagram below explain which way the object would rotate. For more information see NVIDIA docs

A single application of torque would produce one impulse, which may not be enough. In this case consider applying a series of continuous impulses, for example to make a quad bike to roll forward:
onEachFrame { quad addTorque (quad vectorModelToWorld [100,0,0]) };
This command doesn't follow convention for torque direction, which obeys right-hand rule. To comply, negate all values in the vector.
Groups:
Object Manipulation

Syntax

Syntax:
object addTorque torque
Parameters:
object: Object - PhysX object
torque: Array - world vector in format [x,y,z]
Return Value:
Nothing

Examples

Example 1:
Apply torque [1000,0,0] to object not factoring object positioning:
_wheel addTorque [1000,0,0];
Example 2:
Apply torque [1000,0,0] relative to object:
_wheel addTorque (_wheel vectorModelToWorld [1000,0,0]);

Additional Information

See also:
addForce awake isAwake vectorModelToWorld vectorModelToWorldVisual disableBrakes brakesDisabled

Notes

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