---
name: "lineIntersectsObjs"
type: command
status: ok
groups: ["Math - Geometry"]
arma3_since: "1.10"
locality: {"argument": "global", "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/lineIntersectsObjs
revid: 377627
updated: 2026-01-02T08:52:08Z
---

# lineIntersectsObjs

*Command · Math - Geometry · Arma 3 v1.10*

Locality: arguments **global**

## Description

Returns a list of objects intersected by the line from *begPos* to *endPos*. Since Arma 3 v2.20, there is an alternative syntax that does multiple checks in parallel, faster than multiple calls.

## Syntax

### Syntax 1

```sqf
lineIntersectsObjs [begPos, endPos, ignoreObj1, ignoreObj2, sortByDistance, flags]
```

**Parameters:**

- `begPos`: [PositionASL](../topics/Position.md#positionasl) - virtual line start
- `endPos`: [PositionASL](../topics/Position.md#positionasl) - virtual line end
- `ignoreObj1`: [Object](../topics/Object.md) - (Optional) - object to ignore
- `ignoreObj2`: [Object](../topics/Object.md) - (Optional) - object to ignore
- `sortByDistance`: [Boolean](../topics/Boolean.md) - (Optional) - [true](../commands/true.md): furthest object first, closest object last; [false](../commands/false.md): unsorted
- `flags`: [Number](../topics/Number.md) - (Optional)
  - 1 - CF_ONLY_WATER
  - 2 - CF_NEAREST_CONTACT
  - 4 - CF_ONLY_STATIC
  - 8 - CF_ONLY_DYNAMIC
  - 16 - CF_FIRST_CONTACT
  - 32 - CF_ALL_OBJECTS (Usable only with CF_FIRST_CONTACT and it will check one contact per object)
  Flags can be combined: 2 + 4 = 6 is CF_NEAREST_OBJECT + CF_ONLY_STATIC

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

### Syntax 2

*since arma3 2.20*

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

**Parameters:**

- `elementN`: [Array](../topics/Array.md) with [begPos, endPos, ignoreObj1, ignoreObj2, sortByDistance, flags]
  - begPos: [PositionASL](../topics/Position.md#positionasl) - virtual line start
  - endPos: [PositionASL](../topics/Position.md#positionasl) - virtual line end
  - ignoreObj1: [Object](../topics/Object.md) - (Optional) - object to ignore
  - ignoreObj2: [Object](../topics/Object.md) - (Optional) - object to ignore
  - sortByDistance: [Boolean](../topics/Boolean.md) - (Optional) - [true](../commands/true.md): furthest object first, closest object last; [false](../commands/false.md): unsorted
  - flags: [Number](../topics/Number.md) - (Optional)
    - 1 - CF_ONLY_WATER
    - 2 - CF_NEAREST_CONTACT
    - 4 - CF_ONLY_STATIC
    - 8 - CF_ONLY_DYNAMIC
    - 16 - CF_FIRST_CONTACT
    - 32 - CF_ALL_OBJECTS (Usable only with CF_FIRST_CONTACT and it will check one contact per object)
  Flags can be combined: 2 + 4 = 6 is CF_NEAREST_OBJECT + CF_ONLY_STATIC

**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
data = [];
displayFunction = {
    {
        data set [_foreachindex, lineIntersectsObjs [eyePos player, ATLToASL screenToWorld [0.5, 0.5], objNull, objNull, false, _x]];
    } forEach [1, 2, 4, 8, 16, 32];

    hintSilent format ["ONLY_WATER: %1\nNEAREST_CONTACT: %2\nONLY_STATIC: %3\nONLY_DYNAMIC: %4\nFIRST_CONTACT: %5\nALL_OBJECTS: %6",
    data select 0, data select 1, data select 2, data select 3, data select 4, data select 5];
};

["sample_id", "onEachFrame", "displayFunction"] call BIS_fnc_addStackedEventHandler;
// example display objects' array in the middle of the screen sorted by 6 flags
```

### Example 2

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 = lineIntersectsObjs [_enemyDataArray];
```

## See also

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

## Community notes

**AgentRev** — 2016-03-29

Distance sorting is relative to object model center, and not intersect position.

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