path_create(ENTITY*
entity, var nodes, var edges)
Creates an actor path with the given number of nodes and edges, and attaches the given entity to it.
Parameters:
entity - entity pointer
nodes - number of path nodes
edges - number of path edges
Returns:
0 if the path could not be created, otherwise nonzero.
Speed:
Slow
Modifies:
entity - is attached to the path.
Remarks:
- Actor paths (not to be confused with folder paths) are graphs of points (nodes) that are connected through lines (edges). Paths can be edited in the level through WED or created with this function. The attached entities can move along a path with the path_spline function.
- The edges are set up so that the first edge leads from point 1 to point 2, the next edge from point 2 to point 3 and so on. All nodes are set to (0,0,0) by default. Use the path_setnode and path_setedge functions for setting positions and further properties of nodes and edges.
-
The maximum number of paths can be set up through the max_paths variable (default = 100) before loading the level. The overall maximum number of path nodes and edges is 100 * max_paths. When more paths, nodes, or edges are created, path_create returns 0.
Example:
// create a path from 4 points, and let a sphere follow it
void main()
{
max_paths = 1;
level_load(0);
me = ent_create(SPHERE_MDL,NULL,NULL);
vec_scale(my.scale_x,5);
vec_set(my.blue,vector(0,255,255));
my.flags |= LIGHT;
path_create(me,4,4);
path_setnode(me,1,vector(500,250,-100),NULL);
path_setnode(me,2,vector(500,-250,-100),NULL);
path_setnode(me,3,vector(1000,-250,100),NULL);
path_setnode(me,4,vector(1000,250,100),NULL);
var distance = 0;
while(1){
path_spline(me,my.x,distance += 20*time_step);
wait(1);
}
}
See also:
path_scan,
path_next, path_setnode, path_setedge, path_spline,
num_paths, max_paths
► latest
version online