{"name":"lineIntersects","operator":null,"title":"lineIntersects","type":"command","url":"https://community.bistudio.com/wiki/lineIntersects","revid":377702,"updated":"2026-01-02T09:03:32Z","groups":["Math - Geometry"],"status":"ok","replaced_by":[],"games":[{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.62"},{"game":"tkoh","name":"Take On Helicopters","version":"1.00"},{"game":"arma3","name":"Arma 3","version":"0.50"}],"since":{"game":"arma2oa","name":"Arma 2: Operation Arrowhead","version":"1.62"},"arma3_since":"0.50","branch":null,"locality":{"argument":"global","effect":null,"server_exec":false},"exec":null,"description":"Checks for object intersection with a virtual line between two positions. Since Arma 3 v2.20, there is an alternative syntax that does multiple checks in parallel, faster than multiple calls.\n\n> [!NOTE]\n> - Does not work under water.\n> - Max hardcoded distance is 1000m.","syntaxes":[{"syntax":"lineIntersects [begPos, endPos, objIgnore1, objIgnore2]","since":null,"effect":null,"exec":null,"params":[{"name":"begPos","type":"PositionASL","optional":false,"default":null,"description":null,"types":["PositionASL"],"since":null,"text":"begPos: PositionASL"},{"name":"endPos","type":"PositionASL","optional":false,"default":null,"description":null,"types":["PositionASL"],"since":null,"text":"endPos: PositionASL"},{"name":"objIgnore1","type":"Object","optional":true,"default":"objNull","description":"object to ignore. When testing intersections from an object/unit/vehicle, pass that object here to prevent intersections inside of the object","types":["Object"],"since":null,"text":"objIgnore1: Object - (Optional, default objNull) object to ignore. When testing intersections from an object/unit/vehicle, pass that object here to prevent intersections inside of the object"},{"name":"objIgnore2","type":"Object","optional":true,"default":"objNull","description":"another object to ignore. When testing intersections of a line between two objects, pass the second object here to prevent intersections inside of it being reported","types":["Object"],"since":null,"text":"objIgnore2: Object - (Optional, default objNull) another object to ignore. When testing intersections of a line between two objects, pass the second object here to prevent intersections inside of it being reported"}],"returns":{"type":"Boolean","types":["Boolean"],"description":"true if an intersection happens with an object (not with terrain)","text":"Boolean - true if an intersection happens with an object (not with terrain)"},"form":"unary","operator":null,"left":null,"right":{"text":"[begPos, endPos, objIgnore1, objIgnore2]","types":["Array"]}},{"syntax":"lineIntersects [[element1, element2, ...]]","since":"arma3 2.20","effect":null,"exec":null,"params":[{"name":"elementN","type":"Array with [begPos, endPos, objIgnore1, objIgnore2]","optional":true,"default":"objNull","description":"Array with [begPos, endPos, objIgnore1, objIgnore2]\n- begPos: PositionASL\n- endPos: PositionASL\n- objIgnore1: Object -  object to ignore. When testing intersections from an object/unit/vehicle, pass that object here to prevent intersections inside of the object\n- objIgnore2: Object - (Optional, default objNull) another object to ignore. When testing intersections of a line between two objects, pass the second object here to prevent intersections inside of it being reported","types":["Array"],"since":null,"text":"elementN: Array with [begPos, endPos, objIgnore1, objIgnore2]\n- begPos: PositionASL\n- endPos: PositionASL\n- objIgnore1: Object - (Optional, default objNull) object to ignore. When testing intersections from an object/unit/vehicle, pass that object here to prevent intersections inside of the object\n- objIgnore2: Object - (Optional, default objNull) another object to ignore. When testing intersections of a line between two objects, pass the second object here to prevent intersections inside of it being reported"}],"returns":{"type":"Array with [result1, result2, ...]","types":["Array"],"description":"true if an intersection happens with an object (not with terrain) for the Nth element","text":"Array with [result1, result2, ...] - true if an intersection happens with an object (not with terrain) for the Nth element"},"form":"unary","operator":null,"left":null,"right":{"text":"[[element1, element2, ...]]","types":["Array"]}}],"examples":[{"text":"```sqf\nprivate _hasStraightLineToChopper = lineIntersects [eyePos player, aimPos chopper, player, chopper];\n```","code":["private _hasStraightLineToChopper = lineIntersects [eyePos player, aimPos chopper, player, chopper];"]},{"text":"Alternative syntax to check intersections in parallel:\n\n```sqf\nprivate _enemies = units opfor;\nprivate _enemyDataArray = _enemies apply { [eyePos player, aimPos _x, player, _x] };\nprivate _result = lineIntersects [_enemyDataArray];\n```","code":["private _enemies = units opfor;\nprivate _enemyDataArray = _enemies apply { [eyePos player, aimPos _x, player, _x] };\nprivate _result = lineIntersects [_enemyDataArray];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["lineIntersectsSurfaces","lineIntersectsObjs","lineIntersectsWith","terrainIntersect","terrainIntersectASL","terrainIntersectAtASL","intersect","cursorObject","cursorTarget","checkVisibility"],"notes":[{"user":"Lou Montana","date":"2012-05-31T10:46:00Z","text":"Please note the difference:\n- terrainIntersect\n- terrainIntersectASL\n- lineIntersects\n- lineIntersectsWith\n- lineIntersectsObjs\n- intersect"}],"categories":["Arma 2: Operation Arrowhead: New Scripting Commands","Arma 2: Operation Arrowhead: Scripting Commands","Arma 3: Scripting Commands","Command Group: Math - Geometry","Introduced with Arma 2: Operation Arrowhead version 1.62","Scripting Commands","Take On Helicopters: Scripting Commands"]}