Smooth Camera Rotation around 90 degrees

Posted by Nicholas on Game Development See other posts from Game Development or by Nicholas
Published on 2011-11-25T09:30:19Z Indexed on 2011/11/25 10:09 UTC
Read the original article Hit count: 373

Filed under:
|
|

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.

© Game Development or respective owner

Related posts about 3d

Related posts about xna-4.0