#include <acknex.h>
#include <default.c>
float distx,disty,distz,distxy;
void FaceObject(ENTITY* ent1,ENTITY* ent2)
{
distz= ent2.z - ent1.z; //these are the distance variables.
disty= ent2.y - ent1.y; //as you can see,these find
distx= ent2.x - ent1.x; //the distance between the x,y,and z components.
distxy= sqrt(pow(distx,2) + pow(disty,2)); //finding general distance to object
/*I prefer not to use vec_dist() here because
*I have already found the z distance above,
*and I don't need more than the x and y in
*this case.*/
ent1.pan= atan(disty/distx); //using arc tangent to find pan
ent1.tilt= atan(distz/distxy); //and tilt angles.
}
void main()
{
video_mode= 8;
video_screen= 1;
level_load("terr_env.wmb");
wait(3);
camera.z= 250;
ENTITY* face_me= ent_create("dummy.mdl",vector(100,100,100),NULL);
while(1)
{
FaceObject(camera,face_me);
face_me.x+= 10 * time_step;
wait(1);
}
}