Original Post
Hello, I have been trying to get the best way to make a function that rotates my character to face a specific point. I have done something like this: glRotatef( rot-90.0f, 0.0f, 1.0f, 0.0f ); -- Draw my character -- If someone have any better way to do this please feel free to post. Thanks.
#define PIOVER180 0.0174532925199432957692369076848861f
float rot;
void Face(float pointX, float pointZ)
{
float x = pointX - PlayerX;
float z = pointZ - PlayerZ;
if (x!=0 && z<0)
{
rot=((atanf(x/z))/PIOVER180)-180;
}
if (x!=0 && z>0)
{
rot=((atanf(x/z))/PIOVER180);
}
}