Smooth Camera Rotation around 90 degrees
- by Nicholas
I'm developing a third person 3D platformer in XNA. My problem is when I try to rotate the camera around the player.
I would like to rotate (and animate) the camera 90 degrees around the player. So the camera should rotate until it has reached 90 degrees from the starting position.
I cannot figure out how to keep track of the rotation, and when the rotation has made the full 90 degrees.
Currently my cameras update:
public void Update(Vector3 playerPosition) {
if (rotateCamera) {
position = Vector3.Transform(position - playerPosition, Matrix.CreateRotationY(0.1f)) + playerPosition;
}
this.viewMatrix = Matrix.CreateLookAt(position, playerPosition, Vector3.Up);
}
The initial position of the camera is set in the constructor.
The "rotateCamera" bool is set on keypress.
Thanks for the help in advance.
Cheers.