{"name":"lineIntersects","title":"lineIntersects","type":"command","url":"https://community.bistudio.com/wiki/lineIntersects","revid":377702,"updated":"2026-01-02T09:03:32Z","groups":["Math - Geometry"],"status":"ok","games":{"arma2oa":"1.62","tkoh":"1.00","arma3":"0.50"},"since":"arma2oa 1.62","arma3_since":"0.50","locality":{"argument":"global"},"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]","params":[{"name":"begPos","type":"PositionASL","type_expr":"PositionASL"},{"name":"endPos","type":"PositionASL","type_expr":"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","type_expr":"Object","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","type_expr":"Object","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","type_expr":"Boolean","description":"true if an intersection happens with an object (not with terrain)"},"form":"unary","right":{"text":"[begPos, endPos, objIgnore1, objIgnore2]"}},{"syntax":"lineIntersects [[element1, element2, ...]]","since":"arma3 2.20","params":[{"name":"elementN","type":"Array with [begPos, endPos, objIgnore1, objIgnore2]","description":"Array with [begPos, endPos, objIgnore1, objIgnore2]\n\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","type_expr":"Array","text":"elementN: Array with [begPos, endPos, objIgnore1, objIgnore2]\n\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","type_expr":"Array","description":"with [result1, result2, ...] - 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","right":{"text":"[[element1, element2, ...]]"}}],"examples":[{"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];"]}],"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\n- terrainIntersect\n- terrainIntersectASL\n- lineIntersects\n- lineIntersectsWith\n- lineIntersectsObjs\n- intersect"}]}