Repository navigation
A3D_FindNearestByRoute
imshooter edited this page Oct 23, 2026
·
1 revision
Find which of several points the best route from a point reaches first, such as the nearest hospital by road rather than in a straight line.
Every point is weighed in one search, which takes about as long as a few routes.
native A3D_FindNearestByRoute(
Float:x,
Float:y,
Float:z,
const Float:targetX[],
const Float:targetY[],
const Float:targetZ[],
count = sizeof (targetX),
A3D_ROUTE:type = A3D_ROUTE_FASTEST,
Float:heading = -1.0,
Float:reach = 300.0
);| Parameter | Description | Default |
|---|---|---|
Float:x |
Start on the X axis. | |
Float:y |
Start on the Y axis. | |
Float:z |
Start on the Z axis. | |
const Float:targetX[] |
Points on the X axis. | |
const Float:targetY[] |
Points on the Y axis. | |
const Float:targetZ[] |
Points on the Z axis. | |
count |
Number of points. | sizeof (targetX) |
A3D_ROUTE:type |
How the routes weigh the paths. | A3D_ROUTE_FASTEST |
Float:heading |
Direction the vehicle faces at the start, or -1.0 for none. |
-1.0 |
Float:reach |
How far from each point to look for a path, in metres. | 300.0 |
- The index of the point reached first.
-
-1when none can be reached.
The nearest place in a straight line is often not the nearest by road. Across a river, a highway or a hill, the road may go far around. One search weighs every place at once, in about the time of a few routes, much less than measuring each place.
Each place goes to the nearest road within reach. A place with no road within reach is left out.
Finds the hospital nearest to a point by road.
static const Float:gHospitals[][3] = {
{ 1172.0, -1323.0, 15.4 },
{ 2034.0, -1405.0, 17.2 },
{ -2655.0, 639.0, 14.5 },
{ 1607.0, 1818.0, 10.8 }
};
stock NearestHospital(Float:x, Float:y, Float:z) {
new
Float:hospitalX[sizeof (gHospitals)],
Float:hospitalY[sizeof (gHospitals)],
Float:hospitalZ[sizeof (gHospitals)]
;
for (new index; index != sizeof (gHospitals); ++index) {
hospitalX[index] = gHospitals[index][0];
hospitalY[index] = gHospitals[index][1];
hospitalZ[index] = gHospitals[index][2];
}
return A3D_FindNearestByRoute(x, y, z, hospitalX, hospitalY, hospitalZ);
}- A3D_MeasureRoute: Measure the best route between two points without keeping it, which is faster than finding it.
- A3D_FindRoute: Find the best route between two points along the paths of the game.
3DAndreas 0.7.1 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Physics objects
- Model settings
- World queries
- The screen
- Routes
- Navigation mesh
- Map database
- Coming from ColAndreas
- Performance
Reference
Functions