{"name":"positionCameraToWorld","operator":null,"title":"positionCameraToWorld","type":"command","url":"https://community.bistudio.com/wiki/positionCameraToWorld","revid":378531,"updated":"2026-05-04T02:19:23Z","groups":["Camera Control","Positions"],"status":"ok","replaced_by":[],"games":[{"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":"arma1","name":"Armed Assault","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Get the world coordinate space (AGL) from a camera-relative position.","syntaxes":[{"syntax":"positionCameraToWorld cameraPos","since":null,"effect":null,"exec":null,"params":[{"name":"cameraPos","type":"PositionRelative","optional":false,"default":null,"description":"relative camera position, format **[x, z, y]** (X = left-right, Z = below-above, Y = back-front)\n\n> [!IMPORTANT]\n> This command has Y and Z axes swapped around, which is different from the usual model space coordinates format ([x, y, z]).","types":["PositionRelative"],"since":null,"text":"cameraPos: PositionRelative - relative camera position, format **[x, z, y]** (X = left-right, Z = below-above, Y = back-front)\n\n> [!IMPORTANT]\n> This command has Y and Z axes swapped around, which is different from the usual model space coordinates format ([x, y, z])."}],"returns":{"type":"PositionAGL","types":["PositionAGL"],"description":"camera world position","text":"PositionAGL - camera world position"},"form":"unary","operator":null,"left":null,"right":{"text":"cameraPos","types":["PositionRelative"]}}],"examples":[{"text":"```sqf\n_worldPos = positionCameraToWorld _cameraPos;\n```","code":["_worldPos = positionCameraToWorld _cameraPos;"]},{"text":"Example demonstrating reversed Y and Z:\n\n```sqf\nplayer setDir 0; // assuming player is looking forward\nhint str [positionCameraToWorld [0,0,0], positionCameraToWorld [0,0,1]];\n/*\n[\n    [2481.35, 5671.21, 1.51395],\n    [2481.35, 5672.21, 1.46955]\n]\n*/\n```","code":["player setDir 0; // assuming player is looking forward\nhint str [positionCameraToWorld [0,0,0], positionCameraToWorld [0,0,1]];\n/*\n[\n\t[2481.35, 5671.21, 1.51395],\n\t[2481.35, 5672.21, 1.46955]\n]\n*/"]},{"text":"```sqf\n_cameraAGLPosition = positionCameraToWorld [0,0,0];\n```","code":["_cameraAGLPosition = positionCameraToWorld [0,0,0];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["modelToWorld","modelToWorldVisual","getCameraViewDirection","weaponDirection","eyeDirection","vectorDir","vectorDirVisual"],"notes":[{"user":"Kronzky","date":"2008-10-17T11:25:00Z","text":"By measuring the distance between the camera and the player one can determine whether 1st-person or 3rd-person view is being used:\n\n```sqf\nif ((positionCameraToWorld [0,0,0] distance player)>2) then { hint \"3rd person\" } else { hint \"1st person\" };\n```"},{"user":"Worldeater","date":"2010-10-17T22:45:00Z","text":"The camera coordinate system is different from the model coordinate system: when modelToWorld uses [x, y, z] then positionCameraToWorld uses [x, z, y]. So for a steady camera the following is true:\n\n```sqf\npositionCameraToWorld [5,10,15] == _camera modelToWorld [5,15,10];\n```"}],"categories":["ArmA: Armed Assault: New Scripting Commands","ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Camera Control","Command Group: Positions","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}