this faces first one to second:
Code:
void ent_face_first(ENTITY* first,ENTITY* second){
	if(first == NULL || second == NULL){
		printf("Null object in ent_face_first.");
	}	
	VECTOR vec;
	vec_set(vec.x,second.x);
	ANGLE angl;
	vec_set(vec.x,vec_sub(vec.x,first.x));
	vec.z = 0;
	vec_to_angle(angl.pan,vec.x);
	first.pan = angl.pan;
	
}



this faces two objects to each other:

Code:
void ent_face_both(ENTITY* first,ENTITY* second){
	if(first == NULL || second == NULL){
		printf("Null object in ent_face_both.");
	}
	
	VECTOR vec;
	ANGLE angl;
	
	vec_set(vec.x,second.x);
	vec_set(vec.x,vec_sub(vec.x,first.x));
	vec.z = 0;
	vec_to_angle(angl.pan,vec.x);
	first.pan = angl.pan;
	
	vec_set(vec.x,first.x);
	vec_set(vec.x,vec_sub(vec.x,second.x));
	vec_to_angle(angl.pan,vec.x);
	second.pan = angl.pan;
}




a lil exp. i did when i saw the thread:

http://rapidshare.de/files/39985587/face.zip.html
-move the first object with mouse, uncomment ent_face_first and comment ent_face_both to see the other function-

edit: vec.z = 0; lines are NOT needed since i used first.pan = angl.pan;

Last edited by Quadraxas; 07/12/08 22:24.

3333333333