zapat 56 Posted January 23, 2011 I would like to find the road surface in the given radius, if there is a near road segment returned. (by nearRoads) Is there a nice way to do that, or should I start bruteforce x++ and y++ coordinates and isOnRoad? To rephrase the question: what can I do with road segment numbers returned by nearRoads? Share this post Link to post Share on other sites
celery 8 Posted January 23, 2011 _nearest=objNull;_distance=1000;{if (vehicle _unit distance _x<_distance) then {_nearest=_x;_distance=vehicle _unit distance _x}} forEach (vehicle _unit nearRoads 1000) _nearest will be the road segment closest to _unit, and you can getPos it. Share this post Link to post Share on other sites
Muzzleflash 111 Posted January 23, 2011 (edited) Not sure why you refer to the result of nearRoads as "road segment numbers". It is not a number or id that is returned, but an actual road segment (probably 25m length of road) in an object. To rephrase the question: what can I do with road segment numbers returned by nearRoads? Pretty much the same as with any other object I would guess. You can getPos it, use distance etc.. I made a script that uses nearRoads to find road segments inside a trigger or marker area, and on those roads find positions that lies in the side of the road. That script I then use for placing IED for example. Maybe I misunderstood, you wanted to find the area of the surface in the area? Then something like this: _roads = MyPos nearRoads MyRadius; _area = 0; { _road = _x; //Use bounding box on the road here to find the width and length of the road segment and add the product to _area. } forEach _roads; It will not be exactly correct because some roads turn. However, I can't think of any other practical way to find the surface. Edited January 23, 2011 by Muzzleflash Share this post Link to post Share on other sites
zapat 56 Posted January 24, 2011 Thanks guys. I am a bit ashamed now. I got the error "expected object or location" for getPos, and an array containing numbers for road segments, thats what confused me.. I forgot to select one segment for getPos, and I thougth it is not an object, but an ID. :) Gosh, I am careless a lot... As for IEDs: what about using roadsConnectedTo for next segment and then [segment1, segment2] call BIS_fnc_DirTo for getting the road direction then turn 90 degrees add 3meters, place IED... Share this post Link to post Share on other sites
Muzzleflash 111 Posted January 24, 2011 About the IED proposed solution: While you could get the position using your method is seems more complicated than what i'm doing currently using a marker or trigger here referred to as "Area". My algorithm: Find road in Area: - Create random pos in area - Use nearRoads on that position to find roads (radius is less than 500m for example) - Check the roads until one within the Area is found. (If the random point is on the edge of the "Area" then the road segment may lie outside when using nearRoads SomeRadius Find Roadside pos: - Use the boundingbox to determine det width of the road and the length. - Based on that use modelToWorld to find a position on the road at either side and at a random point on the road. Share this post Link to post Share on other sites