inArea: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\|seealso= *\[\[([^ ]+)\]\], \[\[([^ ]+)\]\]" to "|seealso= $1 $2")
No edit summary
 
(14 intermediate revisions by 3 users not shown)
Line 13: Line 13:


|descr= Checks whether given position or object is inside given area. Use [[inAreaArray]] to check multiple positions/objects within area.
|descr= Checks whether given position or object is inside given area. Use [[inAreaArray]] to check multiple positions/objects within area.
{{Feature|important| By default all positions given as [[Array]] or as objects are treated as [[PositionAGL]]. Since {{GVI|arma3|2.20|size= 0.75}} there is an option to force them to [[PositionWorld]] format.}}
{{Feature|informative|This command also supports hexagon area which can be created from ellipse when both a and b are negative.
{{Feature|informative|This command also supports hexagon area which can be created from ellipse when both a and b are negative.
Hexagon ellipses are also supported by both marker creation and [[drawEllipse]].}}
Hexagon ellipses are also supported by both marker creation and [[drawEllipse]].}}
Line 18: Line 19:
|s1= position [[inArea]] area
|s1= position [[inArea]] area


|p1= position: [[Object]] or [[Array]] in format [[Position#Introduction|Position2D]] or [[Position#Introduction|Position3D]]
|p1= position: [[Object]] or [[Array]] in format [[Position#Introduction|Position2D]] or [[Position#Introduction|Position3D]] (must be [[Position#PositionAGL|PositionAGL]] if area is checked in 3D)


|p2= area: [[Object]], [[String]], [[Location]]
|p2= area: [[Object]], [[String]], [[Location]]
Line 27: Line 28:
|r1= [[Boolean]]
|r1= [[Boolean]]


|s2= position [[inArea]] [center, a, b, angle, isRectangle, c]
|s2= position [[inArea]] [center, a, b, angle, isRectangle, c, usePosWorld]


|p21= position: [[Object]] or [[Array]] in format [[Position#Introduction|Position2D]] or [[Position#Introduction|Position3D]]
|p21= position: - [[Object]] and/or [[Position]] to check. [[Position]] must be [[Position#PositionAGL|PositionAGL]] if area is checked in 3D (see note in description)


|p22= center: [[Array]] or [[Object]] - center of the area in format [[Position#Introduction|Position2D]], [[Position#Introduction|Position3D]], [[Object]] or [[Group]]
|p22= center: [[Array]] or [[Object]] - center of the area in format [[Position#Introduction|Position2D]], [[Position#Introduction|Position3D]] (must be [[Position#PositionAGL|PositionAGL]] if area is checked in 3D), [[Object]] or [[Group]]


|p23= a: [[Number]] - x axis (x / 2)
|p23= a: [[Number]] - x axis (x / 2)
Line 37: Line 38:
|p24= b: [[Number]] - y axis (y / 2)
|p24= b: [[Number]] - y axis (y / 2)


|p25= angle: [[Number]] - rotation angle
|p25= angle: [[Number]] - (Optional since 2.20, Default: 0) rotation angle


|p26= isRectangle: [[Boolean]] - [[true]] if rectangle, [[false]] if ellipse
|p26= isRectangle: [[Boolean]] - (Optional since 2.20, Default: false) [[true]] if rectangle, [[false]] if ellipse


|p27= c: [[Number]] - (Optional, default -1 (unlimited)) z axis (z / 2)
|p27= c: [[Number]] - (Optional, default -1 (unlimited)) z axis (z / 2)
|p27since= arma3 1.60
|p27since= arma3 1.60
|p28= usePosWorld: [[Boolean]] - (Optional, default [[false]]) set to [[true]] to treat all positions as [[PositionWorld]]
|p28since= Arma3 2.20


|r2= [[Boolean]]
|r2= [[Boolean]]


|x1= <code>_playerIsInside = [[player]] [[inArea]] _myTrigger;</code>
|x1= <sqf>_playerIsInside = player inArea _myTrigger;</sqf>


|x2= <code>_positionIsInside = _myPosition [[inArea]] [<nowiki/>[100, 100, 0], 20, 30, 45, [[false]]];</code>
|x2= <sqf>_positionIsInside = _myPosition inArea [[100, 100, 0], 20, 30, 45, false];</sqf>


|seealso= [[inAreaArray]] [[triggerArea]] [[in]] [[inPolygon]], [[drawEllipse]], [[drawRectangle]], [[createTrigger]], [[createMarker]], [[createLocation]]
|seealso= [[inAreaArray]] [[triggerArea]] [[in]] [[inPolygon]] [[drawEllipse]] [[drawRectangle]] [[createTrigger]] [[createMarker]] [[createLocation]]
}}
}}

Latest revision as of 18:18, 4 November 2024

Hover & click on the images for description

Description

Description:
Checks whether given position or object is inside given area. Use inAreaArray to check multiple positions/objects within area.
By default all positions given as Array or as objects are treated as PositionAGL. Since Arma 3 logo black.png2.20 there is an option to force them to PositionWorld format.
This command also supports hexagon area which can be created from ellipse when both a and b are negative. Hexagon ellipses are also supported by both marker creation and drawEllipse.
Groups:
TriggersMarkersLocationsPositions

Syntax

Syntax:
position inArea area
Parameters:
position: Object or Array in format Position2D or Position3D (must be PositionAGL if area is checked in 3D)
area: Object, String, Location
Return Value:
Boolean

Alternative Syntax

Syntax:
position inArea [center, a, b, angle, isRectangle, c, usePosWorld]
Parameters:
position: - Object and/or Position to check. Position must be PositionAGL if area is checked in 3D (see note in description)
center: Array or Object - center of the area in format Position2D, Position3D (must be PositionAGL if area is checked in 3D), Object or Group
a: Number - x axis (x / 2)
b: Number - y axis (y / 2)
angle: Number - (Optional since 2.20, Default: 0) rotation angle
isRectangle: Boolean - (Optional since 2.20, Default: false) true if rectangle, false if ellipse
since Arma 3 logo black.png1.60
c: Number - (Optional, default -1 (unlimited)) z axis (z / 2)
since Arma 3 logo black.png2.20
usePosWorld: Boolean - (Optional, default false) set to true to treat all positions as PositionWorld
Return Value:
Boolean

Examples

Example 1:
_playerIsInside = player inArea _myTrigger;
Example 2:
_positionIsInside = _myPosition inArea [[100, 100, 0], 20, 30, 45, false];

Additional Information

See also:
inAreaArray triggerArea in inPolygon drawEllipse drawRectangle createTrigger createMarker createLocation

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