Arma 3 Scripting

lineIntersectsWith

  • Global argument
  • Arma 3 v0.50
  • First in Arma 2: Operation Arrowhead v1.62

Command · Markdown · JSON · original wiki page

Description

Returns objects intersecting with the virtual line from begPos to endPos. By default, the resulting array of intersecting objects is unsorted (see sortByDistance).

Note

  • Does not work under water.
  • Max hardcoded distance is 1000m.

Since Arma 3 v2.20, there is an alternative syntax that does multiple checks in parallel, faster than multiple calls.

Syntax

Syntax 1

lineIntersectsWith [begPos, endPos, objIgnore1, objIgnore2, sortByDistance]

Parameters:

Returns: Array of Objects - intersecting objects

Syntax 2

since arma3 2.20

lineIntersectsWith [[element1, element2, ...]]

Parameters:

Returns: Array with [result1, result2, ...] - each result is an Array of intersecting objects for the Nth element

Examples

Example 1

_objects = lineIntersectsWith [eyePos player, AGLToASL screenToWorld [0.5, 0.5]];

Example 2

Sort by distance:

_objects = lineIntersectsWith [eyePos player, AGLToASL screenToWorld [0.5, 0.5], objNull, objNull, true];

Example 3

Ignore objects:

_objects = lineIntersectsWith [eyePos player, aimPos chopper, player, chopper];

Example 4

Alternative syntax to check intersections in parallel:

private _enemies = units opfor;
private _enemyDataArray = _enemies apply { [eyePos player, aimPos _x, player, _x, true] };
private _result = lineIntersectsWith [_enemyDataArray];

See also

lineIntersectsSurfaces · lineIntersectsObjs · lineIntersects · terrainIntersect · terrainIntersectASL · terrainIntersectAtASL · intersect · cursorObject · cursorTarget · checkVisibility

Community notes

Lou Montana

Please note the difference :

  • terrainIntersect
  • terrainIntersectASL
  • lineIntersects
  • lineIntersectsWith
  • lineIntersectsObjs
  • intersect