addForce: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (formatting)
m (Text replacement - "\[ *(https?:\/\/[^ = ]+) +([^= ]+) *\]" to "{{Link|$1|$2}}")
 
(9 intermediate revisions by 3 users not shown)
Line 2: Line 2:


|game1= arma3
|game1= arma3
|version1= 1.72
|version1= 1.72


Line 11: Line 10:
|gr1= Object Manipulation
|gr1= Object Manipulation


|descr= Applies force to given object at given position. Force is defined as vector [x, y, z] in world space, position is vector [x, y, z] in model space. If you need to define force in model space, use [[vectorModelToWorld]] or [[vectorModelToWorldVisual]] commands first. The force applied as impulse. For more information see [http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxRigidBody.html#a22b0a1ef0b6c5656a6063c5c38f5679c NVIDIA docs]
|descr= Applies impulse force to unit or given PhysX object at given position.
{{Feature|Informative|Since Arma 3 v2.04 this command can be used on units. It will send the unit into unconscious ragdoll state, similar to how [[setUnconscious]] does it (see example 3). In multiplayer, the unit has to be [[local]] {{Icon|localArgument|32}} on the computer that executed command. }}
{{Feature|informative|For more information see {{Link|http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxRigidBody.html|NVIDIA docs}}.}}


|s1= object '''addForce''' [force, position]
|s1= object [[addForce]]  [force, position]


|p1= object: [[Object]] - PhysX object
|p1= object: [[Object]] - PhysX object or {{GVI|arma3|2.04|size= 0.75}}{{Icon|localargument|24}} unit, in which case the unit must be local and will be [[setUnconscious|set unconscious]]


|p2= force: [[Array]] - Force vector (in world space) in format [x,y,z]
|p2= force: [[Array]] - in format [x,y,z], force vector in '''world''' space. Force is in {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/structPxForceMode.html|Newton}}


|p4= position: [[Array]] - Model [[PositionRelative]] to which force is applied in format [x,y,z]
|p3= position: [[Array]] - in format [x,y,z], in ''object''<nowiki/>'s [[Position#PositionRelative|relative position]]


|r1= [[Nothing]]
|r1= [[Nothing]]


|x1= Apply force [0,1000,0] defined in world space (not factoring object actual positioning) to object position [1,0,0]:
|x1= Apply force [0,1000,0] defined in world space (not factoring object actual positioning) to object position [1,0,0]:
<code>_object [[addForce]] [[0,1000,0],[1,0,0]];</code>
<sqf>_object addForce [[0,1000,0], [1,0,0]];</sqf>


|x2= Apply force [0,1000,0] defined in model space (relative to object) to object position [1,0,0]:
|x2= Apply force [0,1000,0] defined in model space (relative to object) to object position [1,0,0]:
<code>_object [[addForce]] [_object [[vectorModelToWorld]] [0,1000,0],[1,0,0]];</code>
<sqf>_object addForce [_object vectorModelToWorld [0,1000,0], [1,0,0]];</sqf>


|x3= Since Arma 3 v2.03.147267, can be used on units: <code>[] [[spawn]]
|x3= Can be used on units since {{arma3}} v2.04:
<sqf>
if (local bob) then
{
{
bob [[addForce]] [bob [[vectorModelToWorld]] [0,-200,0], bob [[selectionPosition]] "rightfoot"];
[] spawn
[[sleep]] 5;
{
bob [[setUnconscious]] [[false]];
bob addForce [bob vectorModelToWorld [0,-200,0], bob selectionPosition "rightfoot"];
};</code>
sleep 5;
bob setUnconscious false;
};
};
</sqf>


|seealso= [[addTorque]], [[vectorModelToWorld]], [[vectorModelToWorldVisual]]
|seealso= [[addTorque]] [[awake]] [[isAwake]] [[vectorModelToWorld]] [[vectorModelToWorldVisual]] [[selectionPosition]] [[disableBrakes]] [[brakesDisabled]]
}}
}}

Latest revision as of 16:11, 28 April 2023

Hover & click on the images for description

Description

Description:
Applies impulse force to unit or given PhysX object at given position.
For more information see NVIDIA docs.
Groups:
Object Manipulation

Syntax

Syntax:
object addForce [force, position]
Parameters:
object: Object - PhysX object or Arma 3 logo black.png2.04LALocal unit, in which case the unit must be local and will be set unconscious
force: Array - in format [x,y,z], force vector in world space. Force is in Newton
position: Array - in format [x,y,z], in object's relative position
Return Value:
Nothing

Examples

Example 1:
Apply force [0,1000,0] defined in world space (not factoring object actual positioning) to object position [1,0,0]:
_object addForce [[0,1000,0], [1,0,0]];
Example 2:
Apply force [0,1000,0] defined in model space (relative to object) to object position [1,0,0]:
_object addForce [_object vectorModelToWorld [0,1000,0], [1,0,0]];
Example 3:
Can be used on units since Arma 3 v2.04:
if (local bob) then { [] spawn { bob addForce [bob vectorModelToWorld [0,-200,0], bob selectionPosition "rightfoot"]; sleep 5; bob setUnconscious false; }; };

Additional Information

See also:
addTorque awake isAwake vectorModelToWorld vectorModelToWorldVisual selectionPosition 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