Jump to content
kibaBG

[SOLVED] Spawning unit in random building position

Recommended Posts

This should be straight forward and easy but I keep getting error _informatorPos is undefined variable. :help:

_validHouses = nearestObjects [[7977.27,8239.2,0], ["house"], 7500]; 
daHouse = selectRandom _validHouses;
_builPositions = [daHouse] call BIS_fnc_buildingPositions;
_informatorPos = selectRandom _builPositions;
informatorGRP = createGroup [civilian, true];
informator = informatorGRP createUnit ["C_Man_casual_1_F_tanoan", _informatorPos, [], 0, "CAN_COLLIDE"];

Maybe there is no building positions in the randomly found house? :shrug: 

Share this post


Link to post
Share on other sites
4 hours ago, kibaBG said:

Maybe there is no building positions in the randomly found house? :shrug: 

Exactly.

  • Like 1

Share this post


Link to post
Share on other sites

Try with nearestTerrainObjects if map houses.
And use buildingPos

 

private _houses = nearestTerrainObjects [[7977.27,8239.2,0],["house"], 750,false,false];
private _validHouses = _houses select { (_x buildingPos -1) isNotEqualTo []};
private _informatorHouse = selectRandom _validHouses;
private _informatorPos = selectRandom ( _informatorHouse buildingPos -1);
private _informator = createGroup Civilian createUnit ["C_Man_casual_1_F_tanoan", _informatorPos, [], 0, "CAN_COLLIDE"];
_informator setDir (boundingCenter _informatorHouse getDir _informator);

 

 

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×