---
name: "nearestBuilding"
type: command
status: ok
groups: ["Object Detection"]
arma3_since: "0.50"
locality: {"argument": null, "effect": null, "server_exec": false}
source: https://community.bistudio.com/wiki/nearestBuilding
revid: 377548
updated: 2026-01-02T06:54:43Z
---

# nearestBuilding

*Command · Object Detection · Arma 3 v0.50 · introduced in Operation Flashpoint v1.00*

## Description

Finds the nearest building to a given object or position. A "building" is defined as an object that is of class "House" and contains a path LOD.

## Syntax

```sqf
nearestBuilding position
```

**Parameters:**

- `position`: [Object](../topics/Object.md) or [Position2D](../topics/Position.md#introduction) or [PositionAGL](../topics/Position.md#positionagl)

**Returns:** [Object](../topics/Object.md)

## Examples

### Example 1

```sqf
_nBuilding = nearestBuilding player;
```

### Example 2

```sqf
_nBuilding = nearestBuilding position player;
```

## See also

[buildingPos](../commands/buildingPos.md) · [nearestObject](../commands/nearestObject.md) · [nearestObjects](../commands/nearestObjects.md) · [nearObjects](../commands/nearObjects.md) · [nearestLocation](../commands/nearestLocation.md) · [nearEntities](../commands/nearEntities.md) · [nearTargets](../commands/nearTargets.md) · [nearSupplies](../commands/nearSupplies.md) · [nearestLocationWithDubbing](../commands/nearestLocationWithDubbing.md) · [nearObjectsReady](../commands/nearObjectsReady.md) · [nearRoads](../commands/nearRoads.md) · [nearestMines](../commands/nearestMines.md)

## Community notes

**Pierre MGI** — 2016-02-18

This command doesn't return any house or building placed in editor (with [createVehicle](../commands/createVehicle.md)). Use [nearestObjects](../commands/nearestObjects.md) instead:

```sqf
nearestObjects [player, ["House", "Building"], 50] select 0
```

---

**Tankbuster** — 2020-12-30

Some large buildings are not found by this command. "Land_Airport_Tower_F", "Land_Offices_01_V1_F" and "Land_Hotel_02_F" are examples.

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