Jump to content
pSiKO

Detect water between two position

Recommended Posts

Hi coders,

I need  some help to make a function that return true if there is water between two position. (in straight line)


I see "calculatePath", but it's not what I need.

the function "lineIntersectsSurfaces" seem powerful, but I'm unable to use it correctly

the same with "terrainIntersect" or "lineIntersectsObjs", I don't know how to use them for that purpose.

is someone have an example of code I can use, I'd be grateful 🙂

Thanks

in my mind it should look like:
(bool) terrainIntersectwater [start, end]

Share this post


Link to post
Share on other sites

Hi, i put together a little code that should be able to do it. Tell if you need further assistance 🙂.
 

/*
Syntax:
[
_pos1, <Array position>
_pos2, <Array position>
_precision <number range 0.001 to 0.5>(optional-default 0.05)
] call soldierXXXX_fnc_checkWater;

example:
_cursorPos = screenToWorld [0.5,0.5];
[position player,_cursorPos] call soldierXXXX_fnc_checkWater;
*/

soldierXXXX_fnc_checkWater = {
scriptName "soldierXXXX_fnc_checkWater";
params ["_pos1","_pos2",["_precision",0.05]];
_isWater = FALSE;
for "_i" from 0 to 1 step _precision do {
_curPos = vectorLinearConversion [0, 1, _i, _pos1, _pos2, true];
if (surfaceIsWater _curPos) exitWith {_isWater = TRUE;};
};
_isWater
};

 

  • Thanks 2

Share this post


Link to post
Share on other sites

hi soldierXXXX,

thank you very much, it's exactly what I looking for!

you help me a lot!

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

×