{"name":"getPos","operator":null,"title":"getPos","type":"command","url":"https://community.bistudio.com/wiki/getPos","revid":377527,"updated":"2026-01-02T06:52:50Z","groups":["Positions"],"status":"ok","replaced_by":[],"games":[{"game":"ofp","name":"Operation Flashpoint","version":"1.00"},{"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":"ofp","name":"Operation Flashpoint","version":"1.00"},"arma3_since":"0.50","branch":null,"locality":{"argument":"global","effect":null,"server_exec":false},"exec":null,"description":"Returns object or location position. If the argument is an object, the return value is in format PositionAGLS.\n\nThe alternative syntax gets the position given distance and heading away from provided object or position - the command equivalent of BIS_fnc_relPos.\n\n> [!IMPORTANT]\n> Do **not** use this command's first syntax to get an object's position in 3D format:\n> - the Z value from this command is **relative** to the surface underneath, and there is no compatible setter command to use it with;\n> the commonly misused code: `_obj1 setPos getPos _obj2` is **absolutely wrong**\n> - this command is significantly **slower** than other position commands because it has to calculate the surface below a position from objects in the (2D) area; its performance therefore suffers from areas with a high density of objects such as cities, and can easily be ~20x slower than other, simpler position commands - see this benchmark.\n> The **only** correct usage of this command is to determine the altitude of an object **from the surface below it** (see #Example 4).","syntaxes":[{"syntax":"getPos object","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"object: Object"}],"returns":{"type":"PositionAGLS","types":["PositionAGLS"],"description":"where Z is the height over the surface underneath","text":"PositionAGLS - where Z is the height over the surface underneath"},"form":"unary","operator":null,"left":null,"right":{"text":"object","types":["Object"]}},{"syntax":"getPos location","since":null,"effect":null,"exec":null,"params":[{"name":"location","type":"Location","optional":false,"default":null,"description":null,"types":["Location"],"since":null,"text":"location: Location"}],"returns":{"type":"PositionAGL","types":["PositionAGL"],"description":"see locationPosition","text":"PositionAGL - see locationPosition"},"form":"unary","operator":null,"left":null,"right":{"text":"location","types":["Location"]}},{"syntax":"origin getPos [distance, heading]","since":"arma3 1.56","effect":null,"exec":null,"params":[{"name":"origin","type":"Object, Position2D or Position3D","optional":false,"default":null,"description":null,"types":["Object","Position2D","Position3D"],"since":null,"text":"origin: Object, Position2D or Position3D"},{"name":"distance","type":"Number","optional":false,"default":null,"description":"distance from position","types":["Number"],"since":null,"text":"distance: Number - distance from position"},{"name":"heading","type":"Number","optional":false,"default":null,"description":"in which compass direction","types":["Number"],"since":null,"text":"heading: Number - in which compass direction"}],"returns":{"type":"PositionAGLS","types":["PositionAGLS"],"description":"the Z value is terrain level Above Ground Level, either 0 over land or getTerrainHeightASL (negative value) over water","text":"PositionAGLS - the Z value is **terrain level Above Ground Level**, either 0 over land or getTerrainHeightASL (negative value) over water"},"form":"binary","operator":null,"left":{"text":"origin","types":["Object","Position2D","Position3D"]},"right":{"text":"[distance, heading]","types":["Array"]}}],"examples":[{"text":"```sqf\nhintSilent str getPos player;\n```","code":["hintSilent str getPos player;"]},{"text":"getPos vs. other methods (over sea). Pay attention to Z values:\n\n```sqf\ngetPos ship;                // [2412.01, 6036.33, -0.839965]\ngetPosATL ship;                // [2412.01, 6036.33, 19.4266]\ngetPosASL ship;                // [2412.01, 6036.33, -0.920066]\ngetPosASLW ship;            // [2412.01, 6036.33, -0.865981]\nvisiblePosition ship;        // [2412.02, 6036.33, -0.837952]\nvisiblePositionASL ship;    // [2412.02, 6036.33, -0.91798]\nposition ship;                // [2412.01, 6036.33, -0.839965]\n```","code":["getPos ship;\t\t\t\t// [2412.01, 6036.33, -0.839965]\ngetPosATL ship;\t\t\t\t// [2412.01, 6036.33, 19.4266]\ngetPosASL ship;\t\t\t\t// [2412.01, 6036.33, -0.920066]\ngetPosASLW ship;\t\t\t// [2412.01, 6036.33, -0.865981]\nvisiblePosition ship;\t\t// [2412.02, 6036.33, -0.837952]\nvisiblePositionASL ship;\t// [2412.02, 6036.33, -0.91798]\nposition ship;\t\t\t\t// [2412.01, 6036.33, -0.839965]"]},{"text":"getPos vs. other methods (over land, on top of a 100m high building). Pay attention to Z values:\n\n```sqf\ngetPos car;                    // [2508.64, 5681.47, 0.0609589]\ngetPosATL car;                // [2508.64, 5681.47, 100.0356369]\ngetPosASL car;                // [2508.64, 5681.47, 171.718]\ngetPosASLW car;                // [2508.64, 5681.47, 171.718]\nvisiblePosition car;        // [2508.64, 5681.47, 0.0609512]\nvisiblePositionASL car;        // [2508.64, 5681.47, 171.718]\nposition car;                // [2508.64, 5681.47, 0.0609589]\n```","code":["getPos car;\t\t\t\t\t// [2508.64, 5681.47, 0.0609589]\ngetPosATL car;\t\t\t\t// [2508.64, 5681.47, 100.0356369]\ngetPosASL car;\t\t\t\t// [2508.64, 5681.47, 171.718]\ngetPosASLW car;\t\t\t\t// [2508.64, 5681.47, 171.718]\nvisiblePosition car;\t\t// [2508.64, 5681.47, 0.0609512]\nvisiblePositionASL car;\t\t// [2508.64, 5681.47, 171.718]\nposition car;\t\t\t\t// [2508.64, 5681.47, 0.0609589]"]},{"text":"Determine if a free-falling unit is close enough to the surface (including buildings, aircraft carriers etc) below to deploy the parachute:\n\n```sqf\nwaitUntil { sleep 1; getPos player select 2 < 200 };\nhint \"Deploying a parachute might be a good idea\";\n```","code":["waitUntil { sleep 1; getPos player select 2 < 200 };\nhint \"Deploying a parachute might be a good idea\";"]},{"text":"Find position 100 metres and 45 degrees from player position:\n\n```sqf\nplayer getPos [100, 45];    // e.g [1834, 2230, 0] if resulting pos is over land\n                            // or [120, 256, -271] if resulting pos is over water\n```","code":["player getPos [100, 45];\t// e.g [1834, 2230, 0] if resulting pos is over land\n\t\t\t\t\t\t\t// or [120, 256, -271] if resulting pos is over water"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["getPosVisual","getRelPos","setPos","Position","position","getPosATL","getPosASL","getPosASLW","visiblePosition","visiblePositionASL","getMarkerPos"],"notes":[{"user":"Dr_Eyeball","date":"2007-02-17T13:43:00Z","text":"`getPos obj select 2` might return the vertical position above ground level, but for a stacked object, it returns the vertical position above the object beneath it. The same problem existed for getPosASL (**pre-Arma 2 games only**). There was a [discussion](http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=e587356595b907e91f96b8817d7f8a26;act=ST;f=71;t=57918) thread in the BIS forums which suggested the use of the command modelToWorld instead to get around this issue where an absolute vertical position is required. ArmA Ver **1.02**."}],"categories":["ArmA: Armed Assault: Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 2: Scripting Commands","Arma 3: Scripting Commands","Command Group: Positions","Introduced with Operation Flashpoint version 1.00","Operation Flashpoint: Elite: Scripting Commands","Operation Flashpoint: New Scripting Commands","Operation Flashpoint: Scripting Commands","Scripting Commands","Take On Helicopters: Scripting Commands"]}