Hello,
I am trying to program an entity to slowly rotate towards an object. I did the following below, which works, but it doesn't account for the fact that if the entity is facing lets say 355 degrees, and it needs to rotate to 5 degrees to point towards object, it goes all the way around the long way to get there. Here is what I have:
vec_set(vTarget_Temp,your.x);
vec_sub(vTarget_Temp,my.x);
vec_to_angle(vTarget_Angle,vTarget_Temp);
if(my.pan > vTarget_Angle.x)
{
my.pan -= time_step;
//if((my.pan - vTarget_Angle.x) > 180){my.pan += time_step;}
//if((my.pan - vTarget_Angle.x) <= 180){my.pan -= time_step;}
}
if(my.pan < vTarget_Angle.x)
{
my.pan += time_step;
//if((my.pan - vTarget_Angle.x) > 180){my.pan += time_step;}
//if((my.pan - vTarget_Angle.x) <= 180){my.pan -= time_step;}
}
wait(1);
You can see the commented out stuff that I was trying to do, but it just was not working right. Any ideas?