setVelocity: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (rm. note - works fine, even for units)
mNo edit summary
 
(58 intermediate revisions by 13 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| ofpr |= Game name
|game1= ofp
|version1= 1.80


|1.8|= Game version
|game2= ofpe
|version2= 1.00


|arg= local |= Arguments in MP
|game3= arma1
|version3= 1.00


|eff= global |= Effects in MP
|game4= arma2
____________________________________________________________________________________________
|version4= 1.00


| Set [[velocity]] (speed vector) of unit.|= Description
|game5= arma2oa
____________________________________________________________________________________________
|version5= 1.50


| [[Object#|Unit|Unit]] '''setVelocity''' [x, z, y] |= Syntax
|game6= tkoh
|version6= 1.00


|p1= [[Object#|Unit|Unit]]: [[Object]] |= Parameter 1
|game7= arma3
|version7= 0.50


|p2= [x, z, y]: [[Array]] [[Number]]s |= Parameter 2
|arg= local


| [[Nothing]] |= Return value
|eff= global
____________________________________________________________________________________________
 
|x1= <code>_truck1 [[setVelocity]] [20, 0, 0]</code> |= Example 1


|x2= Advanced method used for relative acceleration:<code>_vel <nowiki>=</nowiki> velocity _vehicle;<br />_dir <nowiki>=</nowiki> [[direction]] _vehicle;<br />_speed <nowiki>=</nowiki> 10; [[comment]] "Added speed";<br />_vehicle [[setVelocity]] [(_vel [[select]] 0)+([[sin]] _dir*_speed),(_vel [[select]] 1)+
|gr1= Object Manipulation
([[cos]] _dir*_speed),(_vel [[select]] 2)];</code> |= Example 2
____________________________________________________________________________________________


| [[velocity]] |= See also
|descr= Sets [[velocity]] vector of an object in m/s.


}}
{{Feature|important|Since {{GVI|arma3|2.06|size= 0.75}} each velocity component is limited to the range +-5000 m/s.}}
 
|s1= object [[setVelocity]] vector
 
|p1= object: [[Object]]
 
|p2= vector: [[Array]] format [[Vector3D]]
 
|r1= [[Nothing]]
 
|x1= <sqf>_truck1 setVelocity [20, 0, 0];</sqf>


<h3 style="display:none">Notes</h3>
|x2= Advanced method used for relative acceleration:
<dl class="command_description">
<sqf>
<!-- Note Section BEGIN -->
_vel = velocity _vehicle;
_dir = getDir _vehicle;
_additionalSpeed = 10; // in m/s
_vehicle setVelocity [
(_vel select 0) + (sin _dir * _additionalSpeed),
(_vel select 1) + (cos _dir * _additionalSpeed),
(_vel select 2) // horizontal only
];
</sqf>


<!-- Note Section END -->
|seealso= [[velocity]] [[velocityModelSpace]] [[setVelocityModelSpace]] [[setVelocityTransformation]] [[speed]]
</dl>
}}


<h3 style="display:none">Bottom Section</h3>
{{Note
[[Category:Scripting Commands|SETVELOCITY]]
|user= ffur2007slx2_5
[[Category:Scripting Commands OFP 1.96|SETVELOCITY]]
|timestamp= 20140620165000
[[Category:Scripting Commands ArmA|SETVELOCITY]]
|text= {{GVI|arma3|1.22}} [[setVelocity]] will be affected by [[setDir]] and [[setVectorDirAndUp]], so use it after them.
}}

Latest revision as of 05:14, 27 November 2023

Hover & click on the images for description

Description

Description:
Sets velocity vector of an object in m/s.
Since Arma 3 logo black.png2.06 each velocity component is limited to the range +-5000 m/s.
Groups:
Object Manipulation

Syntax

Syntax:
object setVelocity vector
Parameters:
object: Object
vector: Array format Vector3D
Return Value:
Nothing

Examples

Example 1:
_truck1 setVelocity [20, 0, 0];
Example 2:
Advanced method used for relative acceleration:
_vel = velocity _vehicle; _dir = getDir _vehicle; _additionalSpeed = 10; // in m/s _vehicle setVelocity [ (_vel select 0) + (sin _dir * _additionalSpeed), (_vel select 1) + (cos _dir * _additionalSpeed), (_vel select 2) // horizontal only ];

Additional Information

See also:
velocity velocityModelSpace setVelocityModelSpace setVelocityTransformation speed

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
ffur2007slx2_5 - c
Posted on Jun 20, 2014 - 16:50 (UTC)
Arma 3 logo black.png1.22 setVelocity will be affected by setDir and setVectorDirAndUp, so use it after them.