FindNearbyClearPosition
Appearance
| Environment: | Mission Scripting | |
|---|---|---|
| Function: | FindNearbyClearPosition | |
| Function Description: | Finds a clear position within a specified radius and minimum spacing from existing objects, using random direction and distance sampling. It checks terrain surface type and height difference to ensure valid placement, returning a position vector or the original input if no suitable location is found. | |
| File Location: | cmm.positionFunctions.lua | |
| Syntax: | CMM.FindNearbyClearPosition( table vec3 , number radius , number spacing ) | |
| Return Value: | table | |
| Parameters: | Name | Description |
| vec3 | Position table with x, y, z coordinates representing the base position for searching clear space. | |
| radius | Maximum distance in meters from the base position to search for a valid location (defaults to 100 if not provided). | |
| spacing | Minimum distance in meters from any object to ensure clear space (defaults to 10 if not provided or invalid). | |
| Example: | CMM.FindNearbyClearPosition({x=100, y=50, z=10}, 150, 20) | |
| Example Description: | Searches for a clear position within 150 meters of the base location, ensuring at least 20 meters of clearance from all objects, returning a valid position or the original if none found. | |
| Related Functions: | ||
| Notes: | ||