---
name: "lineIntersectsWith"
type: command
status: ok
groups: ["Math - Geometry"]
arma3_since: "0.50"
locality: {"argument": "global", "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/lineIntersectsWith
revid: 378359
updated: 2026-04-03T15:54:33Z
---

# lineIntersectsWith

*Command · Math - Geometry · Arma 3 v0.50 · introduced in Arma 2: Operation Arrowhead v1.62*

Locality: arguments **global**

## Description

Returns objects intersecting with the virtual line from *begPos* to *endPos*. By default, the resulting array of intersecting objects is unsorted (see *[sortByDistance](../commands/lineIntersectsWith.md#syntax)*).

> [!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

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

**Parameters:**

- `begPos`: [PositionASL](../topics/Position.md#positionasl) - virtual line start
- `endPos`: [PositionASL](../topics/Position.md#positionasl) - virtual line end
- `objIgnore1`: [Object](../topics/Object.md) - (Optional) object to ignore. When testing intersections from an object/unit/vehicle, pass that object here to prevent intersections inside of the object.
- `objIgnore2`: [Object](../topics/Object.md) - (Optional) 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
- `sortByDistance`: [Boolean](../topics/Boolean.md) - (Optional) [true](../commands/true.md): sort by **desc**ending distance (furthermost object first, closest object last); [false](../commands/false.md): unsorted

**Returns:** [Array](../topics/Array.md) of [Object](../topics/Object.md)s - intersecting objects

### Syntax 2

*since arma3 2.20*

```sqf
lineIntersectsWith [[element1, element2, ...]]
```

**Parameters:**

- `elementN`: [Array](../topics/Array.md) with [begPos, endPos, objIgnore1, objIgnore2, sortByDistance]
  - begPos: [PositionASL](../topics/Position.md#positionasl) - virtual line start
  - endPos: [PositionASL](../topics/Position.md#positionasl) - virtual line end
  - objIgnore1: [Object](../topics/Object.md) - (Optional) object to ignore. When testing intersections from an object/unit/vehicle, pass that object here to prevent intersections inside of the object.
  - objIgnore2: [Object](../topics/Object.md) - (Optional) 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
  - sortByDistance: [Boolean](../topics/Boolean.md) - (Optional) [true](../commands/true.md): sort by **desc**ending distance (furthermost object first, closest object last); [false](../commands/false.md): unsorted

**Returns:** [Array](../topics/Array.md) with [result1, result2, ...] - each result is an [Array](../topics/Array.md) of intersecting objects for the Nth element

## Examples

### Example 1

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

### Example 2

Sort by distance:

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

### Example 3

Ignore objects:

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

### Example 4

Alternative syntax to check intersections in parallel:

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

## See also

[lineIntersectsSurfaces](../commands/lineIntersectsSurfaces.md) · [lineIntersectsObjs](../commands/lineIntersectsObjs.md) · [lineIntersects](../commands/lineIntersects.md) · [terrainIntersect](../commands/terrainIntersect.md) · [terrainIntersectASL](../commands/terrainIntersectASL.md) · [terrainIntersectAtASL](../commands/terrainIntersectAtASL.md) · [intersect](../commands/intersect.md) · [cursorObject](../commands/cursorObject.md) · [cursorTarget](../commands/cursorTarget.md) · [checkVisibility](../commands/checkVisibility.md)

## Community notes

**Lou Montana** — 2012-05-31

Please note the difference :
- terrainIntersect
- terrainIntersectASL
- lineIntersect***s***
- lineIntersect***s***With
- lineIntersect***s***Objs
- intersect

<sub>Source: [BI Community Wiki — lineIntersectsWith](https://community.bistudio.com/wiki/lineIntersectsWith) (revision 378359).</sub>
