// get the angle to the enemy
VECTOR vDirection;
ANGLE vTargetAngle;
vec_diff(vDirection,enemy.x,my.x);
vec_to_angle(vTargetAngle,vDirection);
// vAngle is now the angle to the enemy.
// Turn right or left depending on the difference
// between the current and the target pan angle
my.pan += time_step * sign(ang(vTargetAngle.pan - my.pan));
Thanks painkiller! I've just added the following line: my.tilt += time_step * sign(ang(vTargetAngle.tilt - my.tilt));
and it works perfectly!
Thanks everyone for the help! I'm gonna have to read up more on engine functions .