weaponDirection: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(see also)
m (template:command argument fix)
Line 15: Line 15:
Returns an array in format [x, y, z]<br><br>
Returns an array in format [x, y, z]<br><br>


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


| vehicleName '''weaponDirection''' weaponName |= Syntax
| vehicleName '''weaponDirection''' weaponName |SYNTAX=


|p1= vehicleName: [[Object]] |= Parameter 1
|p1= vehicleName: [[Object]] |PARAMETER1=


|p2= weaponName: [[String]] |= Parameter 2
|p2= weaponName: [[String]] |PARAMETER2=


| [[Array]] - format [[Vector3D]] |= Return value
| [[Array]] - format [[Vector3D]] |RETURNVALUE=
____________________________________________________________________________________________
____________________________________________________________________________________________
   
   
|x1= <code>_weaponVectorDir = [[player]] [[weaponDirection]] [[currentWeapon]] [[player]];</code> |= Example 1
|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"];
|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"];
Line 38: Line 38:
_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> |= Example 2
};</code> |EXAMPLE2=
____________________________________________________________________________________________
____________________________________________________________________________________________


| [[positionCameraToWorld]], [[getCameraViewDirection]], [[eyeDirection]], [[vectorDir]], [[vectorDirVisual]] |= See also
| [[positionCameraToWorld]], [[getCameraViewDirection]], [[eyeDirection]], [[vectorDir]], [[vectorDirVisual]] |SEEALSO=


}}
}}

Revision as of 15:51, 7 April 2019

-wrong parameter ("Arma") defined!-1.00
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. Returns an array in format [x, y, z]

Alternatively, you can get turret and gun angle in degrees using animationSourcePhase or animationPhase commands
Groups:
Uncategorised

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:
positionCameraToWorldgetCameraViewDirectioneyeDirectionvectorDirvectorDirVisual

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

Notes

Posted on August 18, 2007 - 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 November 11, 2007 - 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 November 13, 2007 - 15:54
UNN
For an alternative to the weaponDirection command, see the following post on the offical forums. On how to obtain the direction of multiple turrets on vehicles. Turret Animations - new forum

Bottom Section

Posted on December 9, 2014 - 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).