{"name":"weaponDirection","operator":null,"title":"weaponDirection","type":"command","url":"https://community.bistudio.com/wiki/weaponDirection","revid":377763,"updated":"2026-01-03T00:59:33Z","groups":["Weapons","Unit Control"],"status":"ok","replaced_by":[],"games":[{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},{"game":"arma1","name":"Armed Assault","version":"1.00"},{"game":"arma2","name":"Arma 2","version":"1.00"},{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.50"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"ofpe","name":"Operation Flashpoint: Elite","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":"global","effect":null,"server_exec":false},"exec":null,"description":"Returns the direction that the vehicle weapon is aiming in. For addons the weapon name must be an entry in CfgWeapons.\n\n> [!NOTE]\n> Turret and gun angle in degrees can also be obtained using animationSourcePhase or animationPhase commands.","syntaxes":[{"syntax":"vehicleName weaponDirection weaponName","since":null,"effect":null,"exec":null,"params":[{"name":"vehicleName","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"vehicleName: Object"},{"name":"weaponName","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"weaponName: String"}],"returns":{"type":"Vector3D","types":["Vector3D"],"description":null,"text":"Vector3D"},"form":"binary","operator":null,"left":{"text":"vehicleName","types":["Object"]},"right":{"text":"weaponName","types":["String"]}}],"examples":[{"text":"```sqf\n_weaponVectorDir = player weaponDirection currentWeapon player;\n```","code":["_weaponVectorDir = player weaponDirection currentWeapon player;"]},{"text":"Draw AI eye direction (green) and weapon direction (red) in 3D:\n\n```sqf\nbob = createGroup east createUnit [\"O_Soldier_F\", [0,0,0], [], 0, \"NONE\"];\nbob setVehiclePosition [player modelToWorld [0,100,0], [], 0, \"NONE\"];\nonEachFrame\n{\n    _beg = ASLToAGL eyePos bob;\n    _endE = _beg vectorAdd (eyeDirection bob vectorMultiply 100);\n    drawLine3D [_beg, _endE, [0,1,0,1]];\n    _endW = _beg vectorAdd (bob weaponDirection currentWeapon bob vectorMultiply 100);\n    drawLine3D [_beg, _endW, [1,0,0,1]];\n};\n```","code":["bob = createGroup east createUnit [\"O_Soldier_F\", [0,0,0], [], 0, \"NONE\"];\nbob setVehiclePosition [player modelToWorld [0,100,0], [], 0, \"NONE\"];\nonEachFrame\n{\n\t_beg = ASLToAGL eyePos bob;\n\t_endE = _beg vectorAdd (eyeDirection bob vectorMultiply 100);\n\tdrawLine3D [_beg, _endE, [0,1,0,1]];\n\t_endW = _beg vectorAdd (bob weaponDirection currentWeapon bob vectorMultiply 100);\n\tdrawLine3D [_beg, _endW, [1,0,0,1]];\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["positionCameraToWorld","getCameraViewDirection","eyeDirection","vectorDir","vectorDirVisual"],"notes":[],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Unit Control","Command Group: Weapons","Introduced with Operation Flashpoint: Elite version 1.00","Operation Flashpoint: Elite: New Scripting Commands","Operation Flashpoint: Elite: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}