{"name":"eyeDirection","title":"eyeDirection","type":"command","url":"https://community.bistudio.com/wiki/eyeDirection","revid":377870,"updated":"2026-01-04T11:39:04Z","groups":["Object Manipulation"],"status":"ok","games":{"arma3":"0.50"},"since":"arma3 0.50","arma3_since":"0.50","locality":{"argument":"global"},"description":"Returns the direction object is watching (eyes, or a vehicle's primary observer).","syntaxes":[{"syntax":"eyeDirection unit","params":[{"name":"unit","type":"Object","type_expr":"Object"}],"returns":{"type":"Vector3D","type_expr":"Vector3D"},"form":"unary","right":{"text":"unit"}}],"examples":[{"text":"Keep a can in front of the player's *face*:\n\n```sqf\nCan = \"Land_Can_V3_F\" createVehicle getPosATL player;\nonEachFrame {\n    _eyePos = eyePos player;\n    _eyeDir = eyeDirection player;\n    Can setPosASL [\n        _eyePos select 0 + (_eyeDir select 0),\n        _eyePos select 1 + (_eyeDir select 1),\n        _eyePos select 2 + (_eyeDir select 2)\n    ]\n};\n```","code":["Can = \"Land_Can_V3_F\" createVehicle getPosATL player;\nonEachFrame {\n\t_eyePos = eyePos player;\n\t_eyeDir = eyeDirection player;\n\tCan setPosASL [\n\t\t_eyePos select 0 + (_eyeDir select 0),\n\t\t_eyePos select 1 + (_eyeDir select 1),\n\t\t_eyePos select 2 + (_eyeDir select 2)\n\t]\n};"]},{"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    _beg = ASLToAGL eyePos Bob;\n\n    _endE = _beg vectorAdd (eyeDirection Bob vectorMultiply 100);\n    drawLine3D [_beg, _endE, [0,1,0,1]];\n\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\t_beg = ASLToAGL eyePos Bob;\n\n\t_endE = _beg vectorAdd (eyeDirection Bob vectorMultiply 100);\n\tdrawLine3D [_beg, _endE, [0,1,0,1]];\n\n\t_endW = _beg vectorAdd (Bob weaponDirection currentWeapon Bob vectorMultiply 100);\n\tdrawLine3D [_beg, _endW, [1,0,0,1]];\n};"]}],"see_also":["positionCameraToWorld","weaponDirection","getCameraViewDirection","vectorDir","vectorDirVisual"],"notes":[{"user":"Killzone_Kid","date":"2014-05-26T19:10:00Z","text":"This command should have really been named *headDirection* instead of eyeDirection as one could mistakenly think that eyes direction of your avatar correspond to the direction of the centre of your screen.\nPlay with the script in Example 1 to find out limitations. If you need centre of screen direction, use positionCameraToWorld instead."}]}