roadAt: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *arma3 * * *\| *([0-2]\.[0-9]{2}) * " to "|game1= arma3 |version1= $1 ")
m (Text replacement - " (\|[pr][0-9]+ *= *[^-]+) *- *A([a-z])" to " $1 - a$2")
 
(20 intermediate revisions by 3 users not shown)
Line 9: Line 9:
|descr= Returns a road segment containing given position, [[objNull]] otherwise. Same as [[isOnRoad]] only returns the actual road object instead of boolean.
|descr= Returns a road segment containing given position, [[objNull]] otherwise. Same as [[isOnRoad]] only returns the actual road object instead of boolean.


|s1= '''roadAt''' position
|s1= [[roadAt]] position


|p1= position: [[Object]] or [[Array]] in format [[PositionAGL]] (especially on bridges) or (since Arma 3 v2.00) [[Position2D]], in which case Z will be automatically deduced as the height of the road surface
|p1= position: [[Object]] or [[Array]] - array in format [[Position#PositionAGL|PositionAGL]] (especially on bridges) or {{GVI|arma3|2.00|size= 0.75}} [[Position#Introduction|Position2D]], in which case Z will be automatically deduced as the height of the road surface


|r1= [[Object]] - road segment or [[objNull]]
|r1= [[Object]] - road segment or [[objNull]]


|x1= <code>_road = [[roadAt]] [[ASLToAGL]] [[getPosASL]] [[player]];</code>
|x1= <sqf>_road = roadAt ASLToAGL getPosASL player;</sqf>


|x2= <code>_isOnRoad = ![[isNull]] [[roadAt]] [[player]];</code>
|x2= <sqf>_isOnRoad = !isNull roadAt player;</sqf>


|x3= For detecting bridges, for example<code>[[getModelInfo]] ([[roadAt]] [[ASLToAGL]] [[getPosASL]] [[player]]); {{cc|["bridgesea_01_f.p3d","a3\structures_f_exp\infrastructure\bridges\bridgesea_01_f.p3d",true]}}</code>
|x3= For detecting bridges, for example:
<sqf>getModelInfo (roadAt ASLToAGL getPosASL player); // ["bridgesea_01_f.p3d", "a3\structures_f_exp\infrastructure\bridges\bridgesea_01_f.p3d", true]</sqf>


|seealso= [[nearRoads]], [[roadsConnectedTo]], [[isOnRoad]], [[surfaceIsWater]], [[getRoadInfo]], [[nearestTerrainObjects]]
|seealso= [[nearRoads]] [[roadsConnectedTo]] [[isOnRoad]] [[surfaceIsWater]] [[getRoadInfo]] [[nearestTerrainObjects]]
}}
}}


<dl class="command_description">
{{Note
 
|user= OOKexOo
<dt></dt>
|timestamp= 20161230214000
<dd class="notedate">Posted on December 30, 2016 - 21:40 (UTC)</dd>
|text= This command does not necessarily return the segment which center is the closest to the given position.<br>
<dt class="note">[[User:OOKexOo|OOKexOo]]</dt>
In order to get such segment use [[nearRoads]].
<dd class="note">
<sqf>_closest_road = (_pos nearRoads 0.1) select 0;</sqf>
This command does not nessecarly return the segment which center is the closest to the given position.<br>
}}
In order to get such segment use [[nearRoads]].<br>
<code>_closest_road &#61; (_pos [[nearRoads]] 0.1) select 0;</code>
</dd>
 
</dl>

Latest revision as of 13:39, 8 November 2023

Hover & click on the images for description

Description

Description:
Returns a road segment containing given position, objNull otherwise. Same as isOnRoad only returns the actual road object instead of boolean.
Groups:
Roads and Airports

Syntax

Syntax:
roadAt position
Parameters:
position: Object or Array - array in format PositionAGL (especially on bridges) or Arma 3 logo black.png2.00 Position2D, in which case Z will be automatically deduced as the height of the road surface
Return Value:
Object - road segment or objNull

Examples

Example 1:
_road = roadAt ASLToAGL getPosASL player;
Example 2:
_isOnRoad = !isNull roadAt player;
Example 3:
For detecting bridges, for example:
getModelInfo (roadAt ASLToAGL getPosASL player); // ["bridgesea_01_f.p3d", "a3\structures_f_exp\infrastructure\bridges\bridgesea_01_f.p3d", true]

Additional Information

See also:
nearRoads roadsConnectedTo isOnRoad surfaceIsWater getRoadInfo nearestTerrainObjects

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
OOKexOo - c
Posted on Dec 30, 2016 - 21:40 (UTC)
This command does not necessarily return the segment which center is the closest to the given position.
In order to get such segment use nearRoads.
_closest_road = (_pos nearRoads 0.1) select 0;