Jump to content

BuildRoadRoute

From CMM Wiki
Return to CMM Command Reference
Environment: Mission Scripting
Function: BuildRoadRoute
Function Description: Constructs a road-based route between two points by finding the closest road points and generating waypoints along the path. If the initial or destination points are not on roads, it projects them to the nearest road segment. The function returns a list of waypoints spaced at a given distance, with optional debug visualization.
File Location: cmm.spawnFunctions.lua
Syntax: CMM.BuildRoadRoute( table InitVec3 , table DestVec3 , number distance , boolean debug )
Return Value: table or nil
Parameters: Name Description
InitVec3{x <number>, y <number>, z <number>} – starting position as a vec3 table; if z is nil, an error is thrown.
DestVec3{x <number>, y <number>, z <number>} – destination position as a vec3 table; if z is nil, an error is thrown.
distancedistance in units between waypoints (defaults to 3000 if not specified).
debugif true, visualizes the route and waypoints using red and black circles on the map.
Example: CMM.BuildRoadRoute({x=100,y=200,z=300},{x=500,y=600,z=700},3000,true)
Example Description: Builds a route from (100,200,300) to (500,600,700) with 3000-unit spacing and enables debug visualization, showing both the path and waypoints on the map.
Related Functions:
Notes: -- TODO BuildRoadRoute is in progress. If Init and Dest are not on roads it needs to add those points as offroad points at the start and end of the route