This has been a long standing problem with me. If you want an entity to face at something then you can use a 'vector to angle' function to set the 'pan' value to what to the desired direction but this doesn't really help. What I am trying to do is get the entity to actually turn, i.e. make the movement between its current pan and the dirrection I want it to face. I also need it to turn left if it would be quicker and right if quicker.
I currently use this
vec_set(temp,my.x);
vec_sub(temp,you.x);
vec_to_angle(my.aim_pan,temp.x); // find the angle needed to face the target
//rotation catch up
if(my.aim_pan != my.pan) // check if it needs to turn, where aim_pan is the desired dirrection
{
my.pan += (my.aim_pan-(my.pan+180))/3*time; // if so turn
}
But it is riddles with glitches, the entities will spin rapidly on the spot occationally and also if they are facing dirrectly away from their target they get stuck. Can anyone suggest a better method?