setVectorDir: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " *\| *EFFECT *= * " to " ")
m (Text replacement - "{{HashLink" to "{{Link")
 
(38 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{RV|type=command
{{RV|type=command


| arma1
|game1= ofpe
|version1= 1.00


|1.00
|game2= arma1
|version2= 1.00
 
|game3= arma2
|version3= 1.00
 
|game4= arma2oa
|version4= 1.50
 
|game5= tkoh
|version5= 1.00
 
|game6= arma3
|version6= 0.50


|arg=local
|arg=local
Line 10: Line 24:
|gr2= Math - Vectors
|gr2= Math - Vectors


| Set object's direction vector. Up vector will remain unchanged.
|descr= Set object's direction vector. Up vector will remain unchanged.


| object '''setVectorDir''' [x,y,z]
|pr= The effect is {{Icon|localeffect|32}} when using [[setVectorDir]] on a mine. Use a position modification to broadcast [[setVectorDir]]'s change (see {{Link|#Example 2}}).


|p1= object: [[Object]]
|s1= object [[setVectorDir]] vectorDir


|p2= [x,y,z]: [[Array]]
|p1= object: [[Object]]


| [[Nothing]]
|p2= vectorDir: [[Array]] format [[Vector3D]]


|x1= <code>[[player]] [[setVectorDir]] [5,6,1];</code>
|r1= [[Nothing]]


|[[vectorDir]], [[vectorUp]], [[setVectorUp]], [[setVectorDirAndUp]], [[vectorDiff]], [[vectorAdd]], [[vectorMultiply]], [[vectorCrossProduct]], [[vectorDistance]], [[vectorMagnitudeSqr]], [[vectorDistanceSqr]], [[vectorCos]], [[vectorMagnitude]], [[vectorDotProduct]], [[vectorNormalized]], [[vectorFromTo]]
|x1= <sqf>player setVectorDir [5,6,1];</sqf>
 
|x2= <sqf>
// provided _myMine is local
_myMine setVectorDir [0.3, 1, 0];
_myMine setPosWorld getPosWorld _myMine; // synchronises the mine's direction over the network (special case)
</sqf>
 
|seealso= [[vectorDir]] [[vectorUp]] [[setVectorUp]] [[setVectorDirAndUp]] [[vectorDiff]] [[vectorAdd]] [[vectorMultiply]] [[vectorCrossProduct]] [[vectorDistance]] [[vectorMagnitudeSqr]] [[vectorDistanceSqr]] [[vectorCos]] [[vectorMagnitude]] [[vectorDotProduct]] [[vectorNormalized]] [[vectorFromTo]]
}}
}}


<dl class="command_description">
{{Note
<!-- Note Section BEGIN -->
|user= Str
<dd class="notedate">Posted on March 16, 2008 - 09:50</dd>
|timestamp= 20080316095000
<dt class="note">[[User:Str|Str]]<dd class="note">Command can be also used to rotate camera in all three axis.
|text= Command can be also used to rotate camera in all three axis.
<dd class="notedate">Posted on 21:06, 3 March 2009 (CET)</dd>
}}
<dt class="note">[[User:General Barron|General Barron]]<dd class="note">
 
setVectorDir can only influence an object's pitch. It can not influence bank. Example:
{{Note
<code>player setVectorDir [0,0,1]</code>
|user= General Barron
|timestamp= 20090303210600
|text= [[setVectorDir]] can only influence an object's pitch. It can not influence bank. Example:
<sqf>player setVectorDir [0,0,1];</sqf>
*If the player is facing 0 degrees (north), then this will do NOTHING.
*If the player is facing 0 degrees (north), then this will do NOTHING.
*If the player is facing 90 degrees (east), then this will make him pitch 90 degrees up.
*If the player is facing 90 degrees (east), then this will make him pitch 90 degrees up.
You can't directly pitch an object beyond 90 degrees, because this would change its facing direction. You must first flip it is direction using setDir, then you must bank the object 180 degrees, THEN you pitch the object appropriately.
You can't directly pitch an object beyond 90 degrees, because this would change its facing direction. You must first flip it is direction using setDir, then you must bank the object 180 degrees, THEN you pitch the object appropriately.
<!-- Note Section END -->
}}
</dl>
 
 
{{GameCategory|ofpe|Scripting Commands}}
{{GameCategory|arma1|Scripting Commands}}
{{GameCategory|arma2|Scripting Commands}}
{{GameCategory|arma3|Scripting Commands}}
{{GameCategory|tkoh|Scripting Commands}}


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= DreadedEntity
<dd class="notedate">Posted on August 17, 2015 - 03:27 (UTC)</dd>
|timestamp= 20150817032700
<dt class="note">[[User:DreadedEntity|DreadedEntity]]</dt>
|text= In Arma 3, [[setVectorDir]] does not control an object's pitch or bank, in fact, it is not possible to change either of those solely using [[setVectorDir]]. This command can only affect horizontal rotation along the x-plane, unless an object first has it is [[vectorUp]] changed to something other than [0,0,1]. Correct input to [[setVectorDir]] should be calculated using the trigonometric functions [[sin]] and [[cos]].
<dd class="note">
In Arma 3, [[setVectorDir]] does not control an object's pitch or bank, in fact, it is not possible to change either of those solely using [[setVectorDir]]. This command can only affect horizontal rotation along the x-plane, unless an object first has it is [[vectorUp]] changed to something other than [0,0,1]. Correct input to [[setVectorDir]] should be calculated using the trigonometric functions [[sin]] and [[cos]].


examples:
examples:
<code>
<sqf>
0 degrees (north)
// 0 degrees (north)
[[player]] [[setVectorDir]]
player setVectorDir
[
[
[[sin]] 0, //equals 0
sin 0, // equals 0
[[cos]] 0, //equals 1
cos 0, // equals 1
1
1
];
];
45 degrees (north-east)
// 45 degrees (north-east)
[[player]] [[setVectorDir]]
player setVectorDir
[
[
[[sin]] 45, //equals 0.707
sin 45, // equals 0.707
[[cos]] 45, //equals 0.707
cos 45, // equals 0.707
1
1
];</code>
];
</sqf>
If you are doing trigonometric calculations, it may be better to use [[setVectorDir]] rather than [[setDir]], since sine and cosine have already been calculated and will not need to be re-calculated
If you are doing trigonometric calculations, it may be better to use [[setVectorDir]] rather than [[setDir]], since sine and cosine have already been calculated and will not need to be re-calculated
(also, [[setDir]] probably uses [[setVectorDir]] anyway.)
(also, [[setDir]] probably uses [[setVectorDir]] anyway.)
</dd>
}}
</dl>
<!-- DISCONTINUE Notes -->

Latest revision as of 18:43, 4 January 2023

Hover & click on the images for description

Description

Description:
Set object's direction vector. Up vector will remain unchanged.
Problems:
The effect is LELocal when using setVectorDir on a mine. Use a position modification to broadcast setVectorDir's change (see Example 2).
Groups:
Math - Vectors

Syntax

Syntax:
object setVectorDir vectorDir
Parameters:
object: Object
vectorDir: Array format Vector3D
Return Value:
Nothing

Examples

Example 1:
player setVectorDir [5,6,1];
Example 2:
// provided _myMine is local _myMine setVectorDir [0.3, 1, 0]; _myMine setPosWorld getPosWorld _myMine; // synchronises the mine's direction over the network (special case)

Additional Information

See also:
vectorDir vectorUp setVectorUp setVectorDirAndUp vectorDiff vectorAdd vectorMultiply vectorCrossProduct vectorDistance vectorMagnitudeSqr vectorDistanceSqr vectorCos vectorMagnitude vectorDotProduct vectorNormalized vectorFromTo

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
Str - c
Posted on Mar 16, 2008 - 09:50 (UTC)
Command can be also used to rotate camera in all three axis.
General Barron - c
Posted on Mar 03, 2009 - 21:06 (UTC)
setVectorDir can only influence an object's pitch. It can not influence bank. Example:
player setVectorDir [0,0,1];
  • If the player is facing 0 degrees (north), then this will do NOTHING.
  • If the player is facing 90 degrees (east), then this will make him pitch 90 degrees up.
You can't directly pitch an object beyond 90 degrees, because this would change its facing direction. You must first flip it is direction using setDir, then you must bank the object 180 degrees, THEN you pitch the object appropriately.
DreadedEntity - c
Posted on Aug 17, 2015 - 03:27 (UTC)
In Arma 3, setVectorDir does not control an object's pitch or bank, in fact, it is not possible to change either of those solely using setVectorDir. This command can only affect horizontal rotation along the x-plane, unless an object first has it is vectorUp changed to something other than [0,0,1]. Correct input to setVectorDir should be calculated using the trigonometric functions sin and cos. examples:
// 0 degrees (north) player setVectorDir [ sin 0, // equals 0 cos 0, // equals 1 1 ]; // 45 degrees (north-east) player setVectorDir [ sin 45, // equals 0.707 cos 45, // equals 0.707 1 ];
If you are doing trigonometric calculations, it may be better to use setVectorDir rather than setDir, since sine and cosine have already been calculated and will not need to be re-calculated (also, setDir probably uses setVectorDir anyway.)