Hi,
I have got my character to rotate so that it faces the direction that it will be moving when the W key is pressed, however this only works for a certain amount to each side. I cannot turn my camera 180 degrees and have the character follow it. The code I am using is shown below.
void Game::calcRotAngle(Model *p) {
float dot = xAxis.DotProduct(heading);
float theta = acos(dot);
float angle = theta * 180/PI;
p->rotAngleZ = -angle;
/*char text[256];
sprintf_s(text, "Angle: %5f", angle);
DebugOut(text);*/
}
The "heading" Vector is calculated from the position the camera is looking at - the camera's eye position to get the forward vector for where the camera is looking.
Can anybody help me to understand why this isn't working as I want it to?
Thanks,
Chris