Page tree
Skip to end of metadata
Go to start of metadata

Introduced in



Description:Searches for an empty ground position, next to an object of the specified type. Can be used to line up identical objects next to each other.


Syntax:[pos, class, dir, offset, radius, condition] call fn_vbs_findEmptyLocation
  • pos: PositionAGL - Position to start the search from.
  • class: String - Class name of object to search for, to find an empty space next to.
  • dir: Number - Direction from found object, in which to check for empty space. If more qualified objects are found in the given direction, then the start position used to find an empty location is reset to that object, so that the empty position is always past the last existing object (optional, default: random 360).
  • offset: Number - Distance from found object, within which to find an empty space (optional, default: 1).
  • radius: Number - Radius around pos, within which to search for the first object of type class (optional, default: 1).
  • condition: Code - Code that must return true, in order for the found object to be considered for placement. Each found object within the search radius is passed to this function as an argument (and can be referenced using _this select 0) (optional, default: true).
Return Value:Array - The next available position (as PositionAGL, with possible snow layers considered). If no objects of the specified class, or no empty spaces were found, then an empty array is returned.


When using functions in VBS versions older than 3.4, certain limitations and requirements should be kept in mind - the main ones being that capitalization of the function name is crucial, and that #include "\vbs2\headers\function_library.hpp" has to be included in every script that utilizes it. More Functions A-Z.


_position = [getPos player,"vbs2_litter",90] call fn_vbs_findEmptyLocation
Create 10 litters, next to an existing one:
// Create the first litter
_pos = player modelToWorld [0,3,0];
_obj = "vbs2_litter" createVehicle _pos; 
_obj setPos _pos;

// Create 10 more next to it, at an angle of 90º, and a distance of 2m
for "_i" from 1 to 10 do {
  _newpos = [_pos,"vbs2_litter",_dir,2,4] call fn_vbs_findEmptyLocation;
  _obj = "vbs2_litter" createVehicle _newpos;
  _obj setPos _newpos;

Only consider litters without anything attached, when looking for an empty space:
_position = [getPos player,"vbs2_litter",90,1,1,{isNull (childAttached (_this select 0))}] call fn_vbs_findEmptyLocation

Additional Information

See also: fn vbs randomPos, nearestObjects, selectBestPlaces, findEmptyPosition