Jump to content
razerhoriizon

Spawning bushes with createSimpleObject

Recommended Posts

Hey there !
I saw that the command 'createSimpleObject' is used only on scripts, or i didn't see that one out of scripts so, i just wonder if it was possible to just put them onto a game logic or on a trigger ? and how can i do that ?
For example, the bush/plant that i want to add is "a3\plants_f\Bush\b_Thistle_Thorn_Green.p3d"

Sorry for that question btw i'm really noob onto scripting but i just wanna add some bushes at a place
Thanks for reading 

Share this post


Link to post
Share on other sites

It seems to work for me:

_posit = player getPos [20, getdir player];

_bush = createSimpleObject ["a3\plants_f\Bush\b_Thistle_Thorn_Green.p3d",(AGLToASL _posit) vectorAdd [0,0,0.3]];

 

 

Share this post


Link to post
Share on other sites

you can place it in initServer.sqf

or in init.sqf with a server condition :

if (isServer) then {

  _bushPositions = < your array of positions here>;

  { _bush = createSimpleObject ["a3\plants_f\Bush\b_Thistle_Thorn_Green.p3d",(AGLToASL _x) vectorAdd [0,0,0.3]] } forEach _bushPositions;

};

Share this post


Link to post
Share on other sites
On 11/28/2017 at 4:45 AM, pierremgi said:

It seems to work for me:

_posit = player getPos [20, getdir player];

_bush = createSimpleObject ["a3\plants_f\Bush\b_Thistle_Thorn_Green.p3d",(AGLToASL _posit) vectorAdd [0,0,0.3]];

 

 

 

Hi Pierremgi, is possible to replace the player position with random position in a marker area?

Share this post


Link to post
Share on other sites

You can randomize a position from any reference like

getpos player

getMarkerPos "yourMarker"

then, something like:

 _posit = getMarkerPos "yourmarker" getPos [markerRadius * random sqrt 1, random 360];

 

Note: the random sqrt 1 factor is a mean for linear distribution from center to border. If not, you have more chance for a point near center (density at random in circle area when called by distance/azimuth)

Note: markerRadius can be found by (markerArea "yourMarker" #0)  if a circle.

 

For ellipse or rectangle, you can add condition and loop til the point is inside the area:

private _greatAxis = (markerSize "yourMarker" #0) max (markerSize "yourMarker" #1);
private "_posit";
while {_posit = getMarkerPos "yourmarker" getPos [_greatAxis * random sqrt 1, random 360]; !(_posit inArea "yourMarker")} do {};
_posit;

 

  • 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

×