BIS fnc findSafePos: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - " \| arma2 \| *([0-9]\.[0-9]{2}) * " to " | arma2 |$1 |game2= arma2oa |version2= 1.50 |game3= tkoh |version3= 1.00 |game4= arma3 |version4= 0.50 ")
m (Text replacement - " \| *(\[\[[a-zA-Z ]+\]\].+) \|x1=" to " |r1=$1 |x1=")
Line 56: Line 56:
* seaPosition: [[Array]] - in format [x,y] or [x,y,z] - default position on water
* seaPosition: [[Array]] - in format [x,y] or [x,y,z] - default position on water


| [[Array]] - in format [x,y] on success. When position cannot be found at all, default map center position is returned, which will be in format [x,y,0]
|r1=[[Array]] - in format [x,y] on success. When position cannot be found at all, default map center position is returned, which will be in format [x,y,0]


|x1= Find position minimum 1m from from player but not further than 150m, not closer than 3m to any other object, not in the water, maximum gradient of 20, not on the shoreline: <code>_pos = [<nowiki/>[[player]], 1, 150, 3, 0, 20, 0] [[call]] [[BIS_fnc_findSafePos]];</code>
|x1= Find position minimum 1m from from player but not further than 150m, not closer than 3m to any other object, not in the water, maximum gradient of 20, not on the shoreline: <code>_pos = [<nowiki/>[[player]], 1, 150, 3, 0, 20, 0] [[call]] [[BIS_fnc_findSafePos]];</code>

Revision as of 20:27, 10 June 2021

Hover & click on the images for description

Description

Description:
Description needed
Execution:
call
Groups:
Positions

Syntax

Syntax:
Syntax needed
Parameters:
center (Optional): center position. Could be one of:
  • Array - Position2D or Position3D - position
  • Object - object which position will be used
  • Nothing - when passing empty array [] or nothing, the world's "safePositionAnchor" entry will be used. (Default: []).
minDist (Optional): Number - minimum distance from the center position. (Default: 0).
maxDist (Optional): Number - maximum distance from the center position. If -1, the world's "safePositionRadius" entry will be used. (Default: -1).
objDist (Optional): Number - minimum distance from the resulting position to the center of nearest object. Specifying quite large distance here will slow the function and might often fail to find suitable position. Recommended value: 0 - 10. (Default: 0).
waterMode (Optional): Number - water mode (Default: 0). Could be one of:
  • 0 - cannot be in water
  • 1 - can either be in water or not
  • 2 - must be in water
maxGrad (Optional): Number - maximum terrain gradient (hill steepness). A quite small non-zero value could result in failure to find suitable position. Recommended: 0.1+ (Default: 0).
shoreMode (Optional): Number - shore mode (Default: 0). Could be one of:
  • 0 - does not have to be at a shore
  • 1 - must be at a shore
blacklistPos (Optional): Array - List of blacklisted areas in format [area1, area2, area3... areaN] (Default: []). Area could be one of:
  • Array - in format [topLeftCorner, bottomRightCorner] - top and bottom coordinates of blacklisted area
  • Object - trigger area
  • String - marker area
  • Location - location
  • Array - array in format [center, distance] or [center, a, b, angle, rect] or [center, a, b, angle, rect, height]
defaultPos (Optional): Array - default position when no position is found (Default: []). Array format is [landPosition, seaPosition], where:
  • landPosition: Array - in format [x,y] or [x,y,z] - default position on land
  • seaPosition: Array - in format [x,y] or [x,y,z] - default position on water
Return Value:
Array - in format [x,y] on success. When position cannot be found at all, default map center position is returned, which will be in format [x,y,0]

Examples

Example 1:
Find position minimum 1m from from player but not further than 150m, not closer than 3m to any other object, not in the water, maximum gradient of 20, not on the shoreline: _pos = [player, 1, 150, 3, 0, 20, 0] call BIS_fnc_findSafePos;
Example 2:
_pos = [getPos player, 2000, 5000, 1, 0, 0.7, 0, [], [getPos player, getPos player]] call BIS_fnc_findSafePos;
Example 3:
_pos = [[], 0, 1000] call BIS_fnc_findSafePos;

Additional Information

See also:
BIS_fnc_randomPosTriggerBIS_fnc_randomPos

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Posted on March 15, 2017 - 19:30 (UTC)
Killzone Kid
To make sure position is not inside a building, increase distance to nearest object param.