addForce: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - " \| *s([0-9]) *= ([^ ]+)? ?'''([a-zA-Z0-9_]+)''' ?([^ ]+)? " to " |s$1= $2 $3 $4 ") |
Lou Montana (talk | contribs) (Add units) |
||
Line 10: | Line 10: | ||
|gr1= Object Manipulation | |gr1= Object Manipulation | ||
|descr= Applies force to given object at given position. | |descr= Applies impulse force to given object at given position. | ||
{{Feature|informative|Since {{arma3}} v2.04 a unit can be the target. If so: | |||
* the unit will be [[setUnconscious|set unconscious]] | |||
* the unit has to be [[Multiplayer Scripting#Locality|local]] | |||
}} | |||
{{Feature|informative|For more information see [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 unit | ||
|p2= force: [[Array]] - | |p2= force: [[Array]] - in format [x,y,z], force vector in '''world''' space. Force is in [https://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/apireference/files/structPxForceMode.html Newton] | ||
| | |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> | <code>_object [[addForce]] [[0,1000,0], [1,0,0]];</code> | ||
|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> | <code>_object [[addForce]] [_object [[vectorModelToWorld]] [0,1000,0], [1,0,0]];</code> | ||
|x3= | |x3= Can be used on units since {{arma3}} v2.04:<code>[[if]] ([[local]] bob) [[then]] | ||
{ | { | ||
bob [[addForce]] [bob [[vectorModelToWorld]] [0,-200,0], bob [[selectionPosition]] "rightfoot"]; | [] [[spawn]] | ||
{ | |||
bob [[addForce]] [bob [[vectorModelToWorld]] [0,-200,0], bob [[selectionPosition]] "rightfoot"]; | |||
[[sleep]] 5; | |||
bob [[setUnconscious]] [[false]]; | |||
}; | |||
};</code> | };</code> | ||
|seealso= [[addTorque]] | |seealso= [[addTorque]] [[vectorModelToWorld]] [[vectorModelToWorldVisual]] [[selectionPosition]] | ||
}} | }} |
Revision as of 17:08, 21 June 2021
Description
- Description:
- Applies impulse force to given object at given position.
- 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
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