You have to normalize the direction vector and then scale it with the speed. Here is the code part of my algorithm to follow a bezier curve:

Php Code:

vec_set(dir,currentNode->next->pos);
vec_sub(dir,currentNode->pos);
vec_normalize(dir,speed*time_step);
while(distToNext>=speed*time_step)
{
	//Interpolate the rotation(Not needed if you don't care about the rotation, cause the c_move is done in absoulute coordination
	var percentDone=1-(distToNext/wholeDist);
	quat_slerp(&quaternInter,&quaternStart,&quaternEnd,percentDone);
	ang_for_quat(my.pan,&quaternInter);
	c_move(me,nullvector,dir,IGNORE_MODELS);
	distToNext=vec_dist(my.x,currentNode->next->pos);
	wait(1);
} 




regards Alain

Last edited by krial057; 01/14/12 14:27.