{"name":"intersect","operator":null,"title":"intersect","type":"command","url":"https://community.bistudio.com/wiki/intersect","revid":377413,"updated":"2026-01-02T06:45:16Z","groups":["Math - Geometry"],"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":"global","effect":null,"server_exec":false},"exec":null,"description":"Finds named selections in object which are in specified LOD, intersected by given section of a line. Return value is in the form of [selection, distance]. Multiple returned arrays are nested within a single array. No intersection returns []. *lodName* could be one of the following:\n- \"FIRE\"\n- \"VIEW\"\n- \"GEOM\"\n- \"IFIRE\" - (\"I\" stands for Indirect, almost the same as FIRE)\n- Arma 3 v2.02 \"PHYSX\" - PhysX geometry LOD","syntaxes":[{"syntax":"[object, lodName] intersect [begPos, endPos]","since":null,"effect":null,"exec":null,"params":[{"name":"object","type":"Object","optional":false,"default":null,"description":null,"types":["Object"],"since":null,"text":"object: Object"},{"name":"lodName","type":"String","optional":false,"default":null,"description":null,"types":["String"],"since":null,"text":"lodName: String"},{"name":"begPos","type":"PositionAGL","optional":false,"default":null,"description":null,"types":["PositionAGL"],"since":null,"text":"begPos: PositionAGL"},{"name":"endPos","type":"PositionAGL","optional":false,"default":null,"description":null,"types":["PositionAGL"],"since":null,"text":"endPos: PositionAGL"}],"returns":{"type":"Array with [selection, distance]","types":["Array"],"description":"selection: String - name of intersected selection - distance: Number - distance from begPos The results are also sorted, closest selection first","text":"Array with [selection, distance]\n- selection: String - name of intersected selection\n- distance: Number - distance from begPos\nThe results are also sorted, closest selection first"},"form":"binary","operator":null,"left":{"text":"[object, lodName]","types":["Array"]},"right":{"text":"[begPos, endPos]","types":["Array"]}}],"examples":[{"text":"```sqf\n[_tank, \"VIEW\"] intersect [[1500, 1500, 2], [1550, 1500, 2]];\n```","code":["[_tank, \"VIEW\"] intersect [[1500, 1500, 2], [1550, 1500, 2]];"]},{"text":"```sqf\nsphere = \"Sign_Sphere10cm_F\" createVehicle [0,0,0];\nonEachFrame {\n    _begPos = positionCameraToWorld [0,0,0];\n    _begPosASL = AGLToASL _begPos;\n    _endPos = positionCameraToWorld [0,0,1000];\n    _endPosASL = AGLToASL _endPos;\n    _ins = lineIntersectsSurfaces [_begPosASL, _endPosASL, player, objNull, true, 1, \"FIRE\", \"NONE\"];\n    if (_ins isEqualTo []) exitWith {sphere setPosASL [0,0,0]};\n    _ins select 0 params [\"_pos\", \"_norm\", \"_obj\", \"_parent\"];\n    if !(getModelInfo _parent select 2) exitWith {sphere setPosASL [0,0,0]};\n    _ins2 = [_parent, \"FIRE\"] intersect [_begPos, _endPos];\n    if (_ins2 isEqualTo []) exitWith {sphere setPosASL [0,0,0]};\n    _ins2 select 0 params [\"_name\", \"_dist\"];\n    _posASL = _begPosASL vectorAdd ((_begPosASL vectorFromTo _endPosASL) vectorMultiply _dist);\n    drawIcon3D [\"\", [1,1,1,1], ASLToAGL _posASL, 0, 0, 0, _name, 1, 0.03, \"PuristaMedium\"];\n    sphere setPosASL _posASL;\n};\n```","code":["sphere = \"Sign_Sphere10cm_F\" createVehicle [0,0,0];\nonEachFrame {\n\t_begPos = positionCameraToWorld [0,0,0];\n\t_begPosASL = AGLToASL _begPos;\n\t_endPos = positionCameraToWorld [0,0,1000];\n\t_endPosASL = AGLToASL _endPos;\n\t_ins = lineIntersectsSurfaces [_begPosASL, _endPosASL, player, objNull, true, 1, \"FIRE\", \"NONE\"];\n\tif (_ins isEqualTo []) exitWith {sphere setPosASL [0,0,0]};\n\t_ins select 0 params [\"_pos\", \"_norm\", \"_obj\", \"_parent\"];\n\tif !(getModelInfo _parent select 2) exitWith {sphere setPosASL [0,0,0]};\n\t_ins2 = [_parent, \"FIRE\"] intersect [_begPos, _endPos];\n\tif (_ins2 isEqualTo []) exitWith {sphere setPosASL [0,0,0]};\n\t_ins2 select 0 params [\"_name\", \"_dist\"];\n\t_posASL = _begPosASL vectorAdd ((_begPosASL vectorFromTo _endPosASL) vectorMultiply _dist);\n\tdrawIcon3D [\"\", [1,1,1,1], ASLToAGL _posASL, 0, 0, 0, _name, 1, 0.03, \"PuristaMedium\"];\n\tsphere setPosASL _posASL;\n};"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["lineIntersectsSurfaces","terrainIntersect","terrainIntersectASL","terrainIntersectAtASL","lineIntersects","lineIntersectsWith","lineIntersectsObjs","cursorObject","cursorTarget","checkVisibility"],"notes":[{"user":"ManDay","date":"2007-07-25T08:37:00Z","text":"The most common LOD is \"*FIRE*\", which identifies the most detailled hitbox used for ammunition."},{"user":"ffur2007slx2_5","date":"2014-03-27T14:52:00Z","text":"Example (In Arma 3 ver 1.14) display returned arrays on cursor entities:\n\n```sqf\nSto = [];\nFn = {\n    {\n        Sto set [_foreachindex,[cursorTarget, _x] intersect [ASLToAGL eyePos player, screenToWorld [0.5,0.5]]];\n    } foreach [\"FIRE\", \"VIEW\", \"GEOM\", \"IFIRE\"];\n    hintSilent format [\"FIRE: %1, VIEW: %2, GEOM: %3, IFIRE: %4\", Sto select 0, Sto select 1, Sto select 2, Sto select 3];\n};\n[\"sample_id\", \"onEachFrame\", \"Fn\"] call BIS_fnc_addStackedEventHandler;\n```\n\nReturn FIRE: [something], VIEW: [something], GEOM: [something], IFIRE: [something]."},{"user":"Killzone_Kid","date":"2015-08-20T18:34:00Z","text":"intersect will spam .rpt if passed to it object has no skeleton. Use getModelInfo to filter out those objects."}],"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: Math - Geometry","Introduced with Armed Assault version 1.00","Scripting Commands","Take On Helicopters: Scripting Commands"]}