addForce: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
m (Some wiki formatting)
Line 28: Line 28:


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


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

Revision as of 19:17, 7 May 2022

Hover & click on the images for description

Description

Description:
Applies impulse force to given PhysX object at given position.
Since Arma 3 v2.04 the command works on units as well:
For more information see NVIDIA docs.
Groups:
Object Manipulation

Syntax

Syntax:
object addForce [force, position]
Parameters:
object: Object - PhysX object or unit
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