I don't think it's more useful than the normal code we would use. I also wonder if it would be any faster, probably not since it will be checking the angles constantly.

Besides, you only need a few lines:

Code:

function turn_towards_target()
{
// get the direction from the entity MY to the entity YOU
vec_set(temp,your.x);
vec_sub(temp,my.x);
vec_to_angle(my.pan,temp); // now MY looks at YOU
}



Simplest approach would be to use pointers for your 'targets' like this:

Code:

entity* target1; //different kind of enemies
entity* target2;
[..]



Then you can use:

Code:

function turn_towards_target()
{
// get the direction from the entity player to the entity target1
vec_set(temp,player.x);
vec_sub(temp,target1.x);
vec_to_angle(target1.pan,temp);
// enemy now looks at player
}



Cheers


PHeMoX, Innervision Software (c) 1995-2008

For more info visit: Innervision Software