Jump to content
Sign in to follow this  
redmotion

Generating random positions - how?

Recommended Posts

Ok. This is the code I've got in a function. It supposed to take a position and distance as an argument and then generate a new random position from there:

_pos = _this select 0;
_Dist = _this select 1;

_posX = ( _pos select 0);
_posY = ( _pos select 1);

_Dist = _Dist + random 1000;

_Angle = random 360;

_posX2 = _posX + _Dist * cos _Angle;
_posY2 = _posY + _Dist * sin _Angle;

_newpos = [ _posX2, _posY2];
_marker = createMarker ["Marker1", _newpos ];

It doesn't work. I'm sure it's to do with an error with the position syntax but I can't work out where or what it is!

Would be grateful for advise or a link to a ready-made random position function! :)

Thanks.

Share this post


Link to post
Share on other sites

It look fine to me, however I would swap sin and cos for "correctness" although it doesn't matter here. Beware that you probably won't see the marker until you set it's shape and type.

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
Sign in to follow this  

×