{"name":"nearestBuilding","title":"nearestBuilding","type":"command","url":"https://community.bistudio.com/wiki/nearestBuilding","revid":377548,"updated":"2026-01-02T06:54:43Z","groups":["Object Detection"],"status":"ok","games":{"ofp":"1.00","ofpe":"1.00","arma1":"1.00","arma2":"1.00","arma2oa":"1.50","tkoh":"1.00","arma3":"0.50"},"since":"ofp 1.00","arma3_since":"0.50","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.","syntaxes":[{"syntax":"nearestBuilding position","params":[{"name":"position","type":"Object or Position2D or PositionAGL","type_expr":"Object | Position2D | PositionAGL"}],"returns":{"type":"Object","type_expr":"Object"},"form":"unary","right":{"text":"position"}}],"examples":[{"code":["_nBuilding = nearestBuilding player;"]},{"code":["_nBuilding = nearestBuilding position player;"]}],"see_also":["buildingPos","nearestObject","nearestObjects","nearObjects","nearestLocation","nearEntities","nearTargets","nearSupplies","nearestLocationWithDubbing","nearObjectsReady","nearRoads","nearestMines"],"notes":[{"user":"Pierre MGI","date":"2016-02-18T20:18:00Z","text":"This command doesn't return any house or building placed in editor (with createVehicle). Use nearestObjects instead:\n\n```sqf\nnearestObjects [player, [\"House\", \"Building\"], 50] select 0\n```"},{"user":"Tankbuster","date":"2020-12-30T16:04:00Z","text":"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."}]}