weaponDirection: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
m (Text replacement - "\{\{Feature *\| *Informative *\| ([^↵]+) *\}\}" to "{{Feature|informative|$1}}")
 
(68 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma |Game name=
|game1= ofpe
|version1= 1.00


|1.00|Game version=
|game2= arma1
|version2= 1.00


|arg= global |Multiplayer Arguments=
|game3= arma2
|version3= 1.00


|gr1= Weapons |GROUP1=
|game4= arma2oa
|version4= 1.50


|gr2= Unit Control |GROUP2=
|game5= tkoh
____________________________________________________________________________________________
|version5= 1.00


| Returns the direction that the vehicle weapon is aiming in. For addons the weapon name must be an entry in CfgWeapons.
|game6= arma3
|version6= 0.50


{{Informative | Alternatively, you can get turret and gun angle in degrees using [[animationSourcePhase]] or [[animationPhase]] commands}}|DESCRIPTION=
|arg= global
____________________________________________________________________________________________


| vehicleName [[weaponDirection]] weaponName |SYNTAX=
|gr1= Weapons


|p1= vehicleName: [[Object]] |PARAMETER1=
|gr2= Unit Control


|p2= weaponName: [[String]] |PARAMETER2=
|descr= Returns the direction that the vehicle weapon is aiming in. For addons the weapon name must be an entry in [[:Category:CfgWeapons|CfgWeapons]].
{{Feature|informative|Turret and gun angle in degrees can also be obtained using [[animationSourcePhase]] or [[animationPhase]] commands.}}


| [[Array]] - format [[Vector3D]] |RETURNVALUE=
|s1= vehicleName [[weaponDirection]] weaponName
____________________________________________________________________________________________
 
|x1= <code>_weaponVectorDir = [[player]] [[weaponDirection]] [[currentWeapon]] [[player]];</code> |EXAMPLE1=


|x2= Draw AI eye direction (green) and weapon direction (red) in 3D: <code>bob = [[createGroup]] [[east]] [[createUnit]] ["O_Soldier_F", [0,0,0], [], 0, "NONE"];
|p1= vehicleName: [[Object]]
bob [[setVehiclePosition]] [<nowiki/>[[player]] [[modelToWorld]] [0,100,0], [], 0, "NONE"];
 
[[onEachFrame]]
|p2= weaponName: [[String]]
 
|r1= [[Array]] - format [[Vector3D]]
 
|x1= <sqf>_weaponVectorDir = player weaponDirection currentWeapon player;</sqf>
 
|x2= Draw AI eye direction (green) and weapon direction (red) in 3D:
<sqf>bob = createGroup east createUnit ["O_Soldier_F", [0,0,0], [], 0, "NONE"];
bob setVehiclePosition [player modelToWorld [0,100,0], [], 0, "NONE"];
onEachFrame
{
{
_beg = [[ASLToAGL]] [[eyePos]] bob;
_beg = ASLToAGL eyePos bob;
_endE = (_beg [[vectorAdd]] ([[eyeDirection]] bob [[vectorMultiply]] 100));
_endE = _beg vectorAdd (eyeDirection bob vectorMultiply 100);
[[drawLine3D]] [ _beg, _endE, [0,1,0,1]];
drawLine3D [_beg, _endE, [0,1,0,1]];
_endW = (_beg [[vectorAdd]] (bob [[weaponDirection]] [[currentWeapon]] bob [[vectorMultiply]] 100));
_endW = _beg vectorAdd (bob weaponDirection currentWeapon bob vectorMultiply 100);
[[drawLine3D]] [_beg, _endW, [1,0,0,1]];
drawLine3D [_beg, _endW, [1,0,0,1]];
};</code> |EXAMPLE2=
};</sqf>
____________________________________________________________________________________________


| [[positionCameraToWorld]], [[getCameraViewDirection]], [[eyeDirection]], [[vectorDir]], [[vectorDirVisual]] |SEEALSO=
|seealso= [[positionCameraToWorld]] [[getCameraViewDirection]] [[eyeDirection]] [[vectorDir]] [[vectorDirVisual]]
}}
}}


<h3 style="display:none">Notes</h3>
<dl class="command_description">
<dl class="command_description">
<!-- Note Section BEGIN -->
 
<dd class="notedate">Posted on August 18, 2007 - 12:18
<dt></dt>
<dt class="note">[[User:HAC_mainframe|HWM mainframe]]
<dd class="notedate">Posted on 2007-08-18 - 12:18</dd>
<dt class="note">[[User:HAC_mainframe|HWM mainframe]]</dt>
<dd class="note">
<dd class="note">
Works great in multiplayer.
Works great in multiplayer.
Line 55: Line 64:
The return array can be processed-converted into degrees as follows:
The return array can be processed-converted into degrees as follows:


<code>_array = _this [[weaponDirection]] "weapon class" ;
<sqf>_array = _this weaponDirection "weapon class";
_dir_degrees = (_array [[select]] 0) [[atan2]] (_array [[select]] 1);</code>
_dir_degrees = (_array select 0) atan2 (_array select 1);</sqf>
</dd>


<dd class="notedate">Posted on November 11, 2007 - 01:41
<dt><dt>
<dt class="note">[[User:Messiah2|MessiahUA]]
<dd class="notedate">Posted on 2007-11-11 - 01:41</dd>
<dt class="note">[[User:Messiah2|MessiahUA]]</dt>
<dd class="note">
<dd class="note">
WeaponClass can only be the primary turret of the vehicle. For example it is not possible to get direction of commander's M2 on M1Abrams.
WeaponClass can only be the primary turret of the vehicle. For example it is not possible to get direction of commander's M2 on M1Abrams.
</dd>


 
<dt><dt>
<dd class="notedate">Posted on November 13, 2007 - 15:54
<dd class="notedate">Posted on 2007-11-13 - 15:54</dd>
<dt class="note">[[User:UNN|UNN]]
<dt class="note">[[User:UNN|UNN]]</dt>
<dd class="note">
<dd class="note">
For an alternative to the weaponDirection command, see the following post on the official forums. On how to obtain the direction of multiple turrets on vehicles.  
For an alternative to the weaponDirection command, see the following post on the official forums. On how to obtain the direction of multiple turrets on vehicles.  


<s>[http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=a25eef63faad0e555557e7e17118a60c;act=ST;f=80;t=69777 Turret Animations]</s> - [http://forums.bistudio.com/showthread.php?t=63918 new forum]
{{Link|link= http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=a25eef63faad0e555557e7e17118a60c;act=ST;f=80;t=69777|text= Turret Animations}} - {{Link|link= http://forums.bistudio.com/showthread.php?t=63918|text= new forum}}
</dd>


<dd class="notedate">Posted on December 9, 2014 - 18:25 (UTC)</dd>
<dt><dt>
<dt class="note">[[User:Mechariuswh|Mechariuswh]]
<dd class="notedate">Posted on 2014-12-09 - 18:25 (UTC)</dd>
<dt class="note">[[User:Mechariuswh|Mechariuswh]]</dt>
<dd class="note">
<dd class="note">
The suggestion above using atan2 and weaponDirection get the direction the barrel of a weapon is pointing, but this is not the same as the direction a shell will be fired (verify this by getting in an M4 Scorcher, parking it on a slope, elevating the barrel "across" the slope and watching the shell come out in third person).  
The suggestion above using [[atan2]] and [[weaponDirection]] get the direction the barrel of a weapon is pointing, but this is not the same as the direction a shell will be fired (verify this by getting in an M4 Scorcher, parking it on a slope, elevating the barrel "across" the slope and watching the shell come out in third person).
 
</dd>
<!-- Note Section END -->
 
<h3 style="display:none">Bottom Section</h3>


[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]
</dl>
[[Category:Scripting Commands OFP Elite |{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Armed Assault|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 2|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Take On Helicopters|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19:11, 15 March 2024

Hover & click on the images for description

Description

Description:
Returns the direction that the vehicle weapon is aiming in. For addons the weapon name must be an entry in CfgWeapons.
Turret and gun angle in degrees can also be obtained using animationSourcePhase or animationPhase commands.
Groups:
WeaponsUnit Control

Syntax

Syntax:
vehicleName weaponDirection weaponName
Parameters:
vehicleName: Object
weaponName: String
Return Value:
Array - format Vector3D

Examples

Example 1:
_weaponVectorDir = player weaponDirection currentWeapon player;
Example 2:
Draw AI eye direction (green) and weapon direction (red) in 3D:
bob = createGroup east createUnit ["O_Soldier_F", [0,0,0], [], 0, "NONE"]; bob setVehiclePosition [player modelToWorld [0,100,0], [], 0, "NONE"]; onEachFrame { _beg = ASLToAGL eyePos bob; _endE = _beg vectorAdd (eyeDirection bob vectorMultiply 100); drawLine3D [_beg, _endE, [0,1,0,1]]; _endW = _beg vectorAdd (bob weaponDirection currentWeapon bob vectorMultiply 100); drawLine3D [_beg, _endW, [1,0,0,1]]; };

Additional Information

See also:
positionCameraToWorld getCameraViewDirection eyeDirection vectorDir vectorDirVisual

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
Posted on 2007-08-18 - 12:18
HWM mainframe
Works great in multiplayer. The numbers are representing offset as follows : [X axis,Y axis,Z axis] The return array can be processed-converted into degrees as follows:
_array = _this weaponDirection "weapon class"; _dir_degrees = (_array select 0) atan2 (_array select 1);
Posted on 2007-11-11 - 01:41
MessiahUA
WeaponClass can only be the primary turret of the vehicle. For example it is not possible to get direction of commander's M2 on M1Abrams.
Posted on 2007-11-13 - 15:54
UNN
For an alternative to the weaponDirection command, see the following post on the official forums. On how to obtain the direction of multiple turrets on vehicles. Turret Animations (dead link) - new forum
Posted on 2014-12-09 - 18:25 (UTC)
Mechariuswh
The suggestion above using atan2 and weaponDirection get the direction the barrel of a weapon is pointing, but this is not the same as the direction a shell will be fired (verify this by getting in an M4 Scorcher, parking it on a slope, elevating the barrel "across" the slope and watching the shell come out in third person).