Jump to content
Sign in to follow this  
1para{god-father}

Move to nearest Shore

Recommended Posts

Need some help please i need to detect if a chopper has crashed @ sea if so find the nearest shore line to the crash.

Any idea how to do that ?

_pos = _this select 0;  // chopper position

////if in water move _pos to nearest land
if (surfaceIsWater _pos) then {   };

///create stuff...

Share this post


Link to post
Share on other sites

I assume _this select 0 is the chopper right?

If so, you need to change the first line of you script:

_chop = (_this select 0);
_xpos = (getPosASL _chop select 0);
_ypos = (getPosASL _chop select 1);

if (surfaceIsWater [_xPos, _yPos]) then
{
     YOUR CODE HERE
};

Share this post


Link to post
Share on other sites
I assume _this select 0 is the chopper right?

If so, you need to change the first line of you script:

_chop = (_this select 0);
_xpos = (getPosASL _chop select 0);
_ypos = (getPosASL _chop select 1);

if (surfaceIsWater [_xPos, _yPos]) then
{
     YOUR CODE HERE
};

His code actually says it as clear as possible:

_pos = _this select 0; // chopper position

First thing coming to my mind is to create a circle around the chopper, starting at a radius of 100m, using some math to get 16 points (positions) on the circle and check if surfaceIsWater forEach position. If none returns true, extend the radius by 100m and repeat until you get at least one result. If you should get more results, select a random one as +-100m won't matter (in my opinion).

Sorry that I can't provide an example, but I don't really have time right now.

Share this post


Link to post
Share on other sites
His code actually says it as clear as possible:

_pos = _this select 0; // chopper position

First thing coming to my mind is to create a circle around the chopper' date=' starting at a radius of 100m, using some math to get 16 points (positions) on the circle and check if surfaceIsWater forEach position. If none returns true, extend the radius by 100m and repeat until you get at least one result. If you should get more results, select a random one as +-100m won't matter (in my opinion).

Sorry that I can't provide an example, but I don't really have time right now.[/quote']

Ahhh that makes sense ill give that a bash :) thanks

Share this post


Link to post
Share on other sites

Like Johnny said, you can do something like that:

_helopos = _this select 0;
_drypos = [];

// Distance loop
For "_i" from 0 to 1000 step 100 do
{
       // direction loop
For "_y" from 0 to 360 step 40 do
{
            _postest = [(_helopos select 0) + (sin _y) * _i, (_helopos  select 1) + (cos _y) * _i, 0];
            If (surfaceIsWater _postest) exitwith
            {
                _drypos = _postest;
            };
       };
      If (!(_drypos isequalto [])) exitwith {};
};

_drypos

It returns an empty array or a valid position.

Share this post


Link to post
Share on other sites
_pos = _this select 0;

if (surfaceIsWater _pos) then {
_position = [_pos, 0, _maxDistance, 10, 0, 0.5, 1] call BIS_fnc_findSafePos;

if ((count _position) > 0) then {_position} else {getArray (configFile >> "CfgWorlds" >> worldName >> "mapcenter")};
};

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  

×