{"name":"getCameraViewDirection","operator":null,"title":"getCameraViewDirection","type":"command","url":"https://community.bistudio.com/wiki/getCameraViewDirection","revid":349460,"updated":"2023-11-08T16:48:37Z","groups":["Object Manipulation"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.58"}],"since":{"game":"arma3","name":"Arma 3","version":"1.58"},"arma3_since":"1.58","branch":null,"locality":{"argument":"global","effect":null,"server_exec":false},"exec":null,"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","since":null,"effect":null,"exec":null,"params":[{"name":"unit","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"unit: Object"}],"returns":{"type":"Array","types":["Array"],"description":"3D Vector","text":"Array - 3D Vector"},"form":"unary","operator":null,"left":null,"right":{"text":"unit","types":["Object"]}}],"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};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["positionCameraToWorld","weaponDirection","eyeDirection","vectorDir","vectorDirVisual"],"notes":[],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: Object Manipulation","Introduced with Arma 3 version 1.58","Scripting Commands"]}