getDir: Difference between revisions

From Bohemia Interactive Community
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>")
m (Text replacement - "<code>([^ ]*)\[\[([a-zA-Z][a-zA-Z0-9_]+)\]\]([^ ]*)<\/code>" to "<code>$1$2$3</code>")
Line 45: Line 45:
|r2= [[Number]]
|r2= [[Number]]


|x1= <code>_azimuth = getDir [[player]];</code>
|x1= <code>_azimuth = getDir player;</code>


|x2= <code>_azimuth = player [[getDir]] tank;</code>
|x2= <code>_azimuth = player getDir tank;</code>


|seealso= [[getDirVisual]] [[direction]] [[getRelDir]]
|seealso= [[getDirVisual]] [[direction]] [[getRelDir]]
Line 60: Line 60:
Be careful when using this command in conjunction with [[BIS_fnc_rotateVector2D]], which rotates vectors counterclockwise as per trigonometric conventions, while [[getDir]] returns a clockwise angle.<br>
Be careful when using this command in conjunction with [[BIS_fnc_rotateVector2D]], which rotates vectors counterclockwise as per trigonometric conventions, while [[getDir]] returns a clockwise angle.<br>
To counter this, simply negate the output of [[getDir]]:
To counter this, simply negate the output of [[getDir]]:
<code>[[0,1,0], '''-('''getDir _object''')'''] [[call]] [[BIS_fnc_rotateVector2D]];</code>
<code>[[0,1,0], '''-('''getDir _object''')'''] call [[BIS_fnc_rotateVector2D]];</code>
</dd>
</dd>


</dl>
</dl>

Revision as of 11:03, 12 May 2022

Hover & click on the images for description

Description

Description:
Returns the object heading in the range 0..360.
Arma 3
The alternative syntax gets heading from one object or position to another object or position, and should be used instead of BIS_fnc_dirTo.
Groups:
Object Manipulation

Syntax

Syntax:
getDir object
Parameters:
object: Object
Return Value:
Number

Alternative Syntax

Syntax:
pos1 getDir pos2
Parameters:
pos1: Object, Position2D or Position3D - from where
pos2: Object, Position2D or Position3D - to where
Return Value:
Number

Examples

Example 1:
_azimuth = getDir player;
Example 2:
_azimuth = player getDir tank;

Additional Information

See also:
getDirVisual direction getRelDir

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord.
Only post proven facts here! Add Note
Posted on October 23, 2013
AgentRev
Be careful when using this command in conjunction with BIS_fnc_rotateVector2D, which rotates vectors counterclockwise as per trigonometric conventions, while getDir returns a clockwise angle.
To counter this, simply negate the output of getDir: [[0,1,0], -(getDir _object)] call BIS_fnc_rotateVector2D;