{"name":"getCameraViewDirection","title":"getCameraViewDirection","type":"command","url":"https://community.bistudio.com/wiki/getCameraViewDirection","revid":349460,"updated":"2023-11-08T16:48:37Z","groups":["Object Manipulation"],"status":"ok","games":{"arma3":"1.58"},"since":"arma3 1.58","arma3_since":"1.58","locality":{"argument":"global"},"description":"Returns the direction unit is looking in render time scope. While for AI the origin for the view direction vector can be taken from `eyePos unit`, for human player the origin should be taken from player camera position `positionCameraToWorld [0,0,0]`","syntaxes":[{"syntax":"getCameraViewDirection unit","params":[{"name":"unit","type":"Object","type_expr":"Object"}],"returns":{"type":"Array","type_expr":"Array","description":"3D Vector"},"form":"unary","right":{"text":"unit"}}],"examples":[{"text":"Draw AI eye direction (green), weapon direction (red) and camera direction (blue) 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    _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    _endV = (_beg vectorAdd (getCameraViewDirection Bob vectorMultiply 100));\n    drawLine3D [_beg, _endV, [0,0,1,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\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\t_endV = (_beg vectorAdd (getCameraViewDirection Bob vectorMultiply 100));\n\tdrawLine3D [_beg, _endV, [0,0,1,1]];\n};"]}],"see_also":["positionCameraToWorld","weaponDirection","eyeDirection","vectorDir","vectorDirVisual"]}