3D movement - Part III
The player must also turn left and right. To do this we take the same DeltaX and DeltaY values we found in part II:
We then must state the length of the green arrow. The length can be found using the Pythagorean theorem:
The length of the arrow, or radius of our circle, is 11.18.
To find the position of the camera target when rotating around the camera, use the following equation based upon DeltaX and DeltaY, and the Radius.
To compensate for the fact that the camera will not always be located at (0,0), we should add:
The camera target is placed at these X and Y coordinates while the camera remains stationary.
Now we tell the computer to add to the degree rotation when the left arrow is pressed, and to subtract from it when the right arrow is pressed. The player is now capable of rotating fully 360 degrees both left and right.