Jump to content

Recommended Posts

Could somebody help on how to spawn something near these bushes using NearestTerrainObjects and not spawning twice on same pos.

_allBushes = nearestTerrainObjects [player, [Bush], 250, false];

for "_i" from 1 to 5 do

_pos = selectRandom _allBushes

_grp = createGroup east;

_unit = _grp createUnit ["C_man_p_beggar_F", [0,0,0], [], 0, "FORM"];

_unit setPos _pos;

};

 

Share this post


Link to post
Share on other sites

There you go

_allBushes = nearestTerrainObjects [player, [Bush], 250, false];

for "_i" from 1 to 5 do
{
if(count _allBushes == 0) exitWith {};

// Get random bush and delete it from list
_index = floor random (count _allBushes);
_pos = getpos (_allBushes # _index);
_allBushes deleteAt _index;

_grp = createGroup east;

_unit = _grp createUnit ["C_man_p_beggar_F", [0,0,0], [], 0, "FORM"];

_unit setPos _pos;

};
  • Like 2

Share this post


Link to post
Share on other sites
On 9/11/2020 at 10:53 AM, gc8 said:

_allBushes = nearestTerrainObjects [player, [Bush], 250, false];

Is it possible to add a max limit of how many positions it can find? Instead of all bushes in a 250m radius i would like it to be something like 15 bushes in a 250m radius.

Share this post


Link to post
Share on other sites
1 hour ago, Robustcolor said:

Is it possible to add a max limit of how many positions it can find? Instead of all bushes in a 250m radius i would like it to be something like 15 bushes in a 250m radius.

 

you can try:

 

_someBushes = _allBushes select [0,15];

 

but I don't know if the bushes will be evenly distributed. For that you may need random selection

 

 

 

Share this post


Link to post
Share on other sites

Make sure Bush is in quotes:

 

_allBushes = nearestTerrainObjects [player, ["Bush"], 250, false];

  • Like 2

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

×