MIST getPointAtDistanceOnPath

From DCS World Wiki - Hoggitworld.com


Added with: Mist 4.5
Returns the point and heading at a given distance along a given path.

If optional roadType is passed and the path length is only 2 points, then the function will generate a path via land.findPathOnRoads. By default it assumes 'roads' but can be given 'railroads' value.

Optional returnFormat accepts strings of "vec2" or "vec3", by default it returns in vec2.

table, number mist.getPointAtDistanceOnPath(table path ,number distance , string roadType ,string returnFormat )
Valid Input Values:
{[1] = {x = 2300, y = 234526}, [2] = {x = 2300, y = -2352},[3] = {x = 35235, y = -564156},[4] = {x = 54, y = 48456456}, }
Return value:
table, number
Return example:
Usage Examples:
The following example would adjust the coordinates of a group that is about to be spawned so that units are aligned on a road at a given interval.
   local rPath = land.findPathOnRoads('roads', spawnPoint.x, spawnPoint.y, roadEnd.x, roadEnd.y)
   for i = 2, #newGroup.units do
        local newCoord, heading = getPointAtDistanceOnPath(rPath, (i-1)* 10)
        newGroup.units[i].x = newCoord.x
        newGroup.units[i].y = newCoord.y
        newGroup.units[i].heading = heading
Related Functions
makeUnitTable, getRandPointInCircle, getRandomPointInZone, isTerrainValid, terrainHeightDiff, getUnitsInZones, getUnitsInMovingZones, pointInPolygon, getUnitsInPolygon, getDeadMapObjsInZones, getDeadMapObjsInPolygonZone, getUnitsLOS, random, randomizeNumTable, stringMatch, getAvgPoint, getQFE, getPathLength, getPathInSegments, getPointAtDistanceOnPath, projectPoint

Scripting Engine

MIST Root Page