addForce: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{Command|= ____________________________________________________________________________________________ |arma3 |= Game |dev|= Game Version |arg= |= Multiplayer Arguments |ef...")
 
(Add setUnconscious)
 
(38 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command|=
{{RV|type=command
____________________________________________________________________________________________
 
|arma3 |= Game
|game1= arma3
|dev|= Game Version
|version1= 1.72
|arg= |= Multiplayer Arguments
 
|eff= |= Multiplayer Effects
|arg= global
____________________________________________________________________________________________
 
| 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. |= Description
|eff= global
____________________________________________________________________________________________
 
| [[object]] addForce [[x, y, z],[x, y, z]] |= Syntax
|gr1= Object Manipulation
|p1= object: [[Object]] |= Parameter 1
 
|p2= [[x1, y1, z1],[x2, y2, z2]]: [[Array]] |= Parameter 2
|descr= Applies impulse force to unit or given PhysX object at given position.
|p3= [x1, y1, z1]: [[Array]] - force (in world space) |= Parameter 3
{{Feature|informative|For more information see {{Link|http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/classPxRigidBody.html|NVIDIA docs}}.}}
|p4= [x2, y2, z2]: [[Array]] - position (in model space) |= Parameter 4
 
|p5=  |= Parameter 5
|s1= object [[addForce]] [force, position, setUnconscious]
|p6=  |= Parameter 6
 
| [[Nothing]] |= Return Value
|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]]
|x1= Apply force [0,10000,0] defined in world space (not factoring object actual positioning) to object position [1,0,0]:
 
<code>_object addForce [[0,10000,0],[1,0,0]];</code>|= Example 1
|p2= force: [[Array]] - in format [x,y,z], force vector in '''world''' space; force is expressed in {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/structPxForceMode.html|Newton}}
|x2= Apply force [0,10000,0] defined in model space (relative to object) to object position [1,0,0]:
 
<code>_object addForce [_object vectorModelToWorld [0,10000,0],[1,0,0]];</code>|= Example 2
|p3= position: [[Array]] - in format [x,y,z], in ''object''<nowiki/>'s [[Position#PositionRelative|relative position]]
|[[addTorque]], [[vectorModelToWorld]], [[vectorModelToWorldVisual]] |= See Also
 
}}
|p4= setUnconscious: [[Boolean]] - (Optional, default [[true]]) only applies to "CAManBase" ''object''; set to [[false]] to keep the person conscious
|p4since= arma3 2.18
 
|r1= [[Nothing]]
 
|x1= Apply force [0,1000,0] defined in world space (not factoring object actual positioning) to object position [1,0,0]:
<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]:
<sqf>_object addForce [_object vectorModelToWorld [0,1000,0], [1,0,0]];</sqf>


<dl class='command_description'>
|x3= Can be used on units since {{arma3}} v2.04:
<!-- BEGIN Note Section -->
<sqf>
<!-- For example:
if (local bob) then
<dd class='notedate'>Posted on Month Day, Year - Time (UTC)</dd>
{
<dt class='note'>'''[[User:User Name|User Name]]'''</dt>
0 spawn
<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>
bob addForce [bob vectorModelToWorld [0,-200,0], bob selectionPosition "rightfoot"];
-->
sleep 5;
<!-- END Note Section -->
bob setUnconscious false;
</dl>
};
};
</sqf>


<h3 style='display:none'>Bottom Section</h3>
|x4= <sqf>
<!-- Appropriate categories go here -->
player addForce [player vectorModelToWorld [0, -1, 0], [0, 1, 0], false]; // not unconscious
</sqf>


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

Latest revision as of 13:27, 13 May 2024

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, setUnconscious]
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 expressed in Newton
position: Array - in format [x,y,z], in object's relative position
since Arma 3 logo black.png2.18
setUnconscious: Boolean - (Optional, default true) only applies to "CAManBase" object; set to false to keep the person conscious
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 { 0 spawn { bob addForce [bob vectorModelToWorld [0,-200,0], bob selectionPosition "rightfoot"]; sleep 5; bob setUnconscious false; }; };
Example 4:
player addForce [player vectorModelToWorld [0, -1, 0], [0, 1, 0], false]; // not unconscious

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