path_spline(ENTITY*, VECTOR* pos, var dist)

Movement along a path. This function calculates a smooth spline curve along a closed loop path, and sets the pos vector to the calculated curve position that corresponds to the given distance on the path. This can be used for smoothly moving actors, vehicles, or cameras along a path.

Parameters:

ENTITY* - pointer to an entity attached to a path.
pos
- vector to receive the calculated curve position.
dist - distance on the path to calculate the curve position for.

Returns:

Number of the node before the calculated position.

Modifies:

pos - set to a position on the spline curve.

Speed:

Medium

Remarks:

Example (see also path_create):

//call camera_path(""); to let the camera run along a path in the level
function camera_path(pathname)
{
// create a dummy path entity
	me = ent_create(NULL,nullvector,NULL);
	path_set(me,pathname);
	var dist = 0;
	var vLastPos[3];
	var vDir[3];
	while(1) 
	{
// place the camera on the path
		path_spline(me,camera.x,dist);
		dist += 5*time_step;
// let the camera look ahead	
		vec_diff(vDir,camera.x,vLastPos);
		vec_to_angle(camera.pan,vDir);
		vec_set(vLastPos,camera.x);
		wait(1);
	}
}

See also:

path_create, path_scan, path_nextnode, path_setedge, path_length

► latest version online