Hello dear friends,
I want myObject to be setPos'd at a random buildingPos, in the building nearest to myObject.
Since myObject can start pretty much anywhere in a city I have to search/find a close buildingPos that exists.
script:
_houseArray = nearestObjects [myObject, ["House"], 500];
_house = _houseArray select 0;
_x = 0;
while { format ["%1", _house buildingPos _x] != "[0,0,0]" } do {_x = _x + 1};
_x = _x - 1;
myObject setPos (_house buildingpos (ceil random _x));
This works great as long as the nearest enterable "House" with an actual "buildingPos" is close enough (very close, 10m). However, if there is no such "House" close by, myObject is setPos'd into the sea (I guess pos [0,0,0]) even though myObject was less than 50 meters away from a building that actually should work, and my building search still had a radius of 500m. STRANGE!!! OR???
Grateful for any input.
Laggy