ENTITY* walker01;
action moveontrack_01()
{
var walk_percentage;
var distance = 0;
var walking_speed =10;
VECTOR vecLastposition;
VECTOR vecDirection;
var vDir[3];
walker01 =me;
path_set(me, "path_000");
var nPathLength = path_length ( me );
while(1)
{
path_spline(walker01, my.x, distance);
vec_diff(vDir,my.x,vecLastposition);
vec_to_angle(my.pan,vDir);
vec_set(vecLastposition,my.x);
distance += walking_speed * time_step;
if ( ( distance < 0 ) || ( distance > nPathLength ) )
{
walking_speed *= -1;
distance = clamp ( distance, 0, nPathLength );
}
wait(1);
ent_animate(my, "walk", walk_percentage, ANM_CYCLE); // play the "walk" animation
walk_percentage += 5 * time_step; // "3" controls the animation speed
}
}