addForce: Difference between revisions
| m (Text replacement - " <h3 style='display:none'>Bottom Section</h3>" to "") |  (Change force (an impulse) unit to newton-seconds) | ||
| (24 intermediate revisions by 5 users not shown) | |||
| Line 1: | Line 1: | ||
| {{ | {{RV|type=command | ||
| |arma3 |=  | |||
| |game1= arma3 | |||
| |version1= 1.72 | |||
| |arg= global | |arg= global | ||
| |eff= global | |eff= global | ||
| |gr1= Object  | |gr1= PhysX | ||
| |descr= Applies given force for one frame (essentially an impulse) to unit or given PhysX object at given position. | |||
| {{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, setUnconscious] | |||
| |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]] - in format [x,y,z], force vector in '''world''' space; force is expressed in | |||
| {{Link|https://en.wikipedia.org/wiki/Newton-second|newton-seconds}} (used by {{Link|https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/structPxForceMode.html|PxForceMode::eIMPULSE}}) | |||
| |p3= position: [[Array]] - in format [x,y,z], in ''object''<nowiki/>'s [[Position#PositionRelative|relative position]] | |||
| |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]: | |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]: | |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> | ||
| |x3= Can be used on units since {{arma3}} v2.04: | |||
| <sqf> | |||
| if (local bob) then | |||
| { | |||
| 	0 spawn  | |||
| < | 	{ | ||
| 		bob addForce [bob vectorModelToWorld [0,-200,0], bob selectionPosition "rightfoot"]; | |||
| 		sleep 5; | |||
| 		bob setUnconscious false; | |||
| </ | 	}; | ||
| }; | |||
| </sqf> | |||
| |x4= <sqf> | |||
| player addForce [player vectorModelToWorld [0, -1, 0], [0, 1, 0], false]; // not unconscious | |||
| </sqf> | |||
| |seealso= [[addTorque]] [[awake]] [[isAwake]] [[vectorModelToWorld]] [[vectorModelToWorldVisual]] [[selectionPosition]] [[disableBrakes]] [[brakesDisabled]] | |||
| }} | |||
| [[ | |||
Latest revision as of 12:40, 4 July 2025
Description
- Description:
- Applies given force for one frame (essentially an impulse) to unit or given PhysX object at given position.
- Groups:
- PhysX
Syntax
- Syntax:
- object addForce [force, position, setUnconscious]
- Parameters:
- object: Object - PhysX object or  2.04LALocal unit, in which case the unit must be local and will be set unconscious 2.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-seconds (used by PxForceMode::eIMPULSE)
- position: Array - in format [x,y,z], in object's relative position
- since  2.18 2.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]:
- 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:
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
 
	