I have a 3rd person camera which rotates around the Y axis fine (yaw) and when I am facing forward (0, 0, -1) moving the mouse up moves the camera up and down great. But the more I turn the player and camera the the less the camera moves up and down until I get to 90 degrees where it almost stay still and at 180 it moving the mouse up moves the camera down!

Any ideas? How should I be calculating camera pitch? The player only yaws - it does not roll or pitch. The camera yaws and pitches. The cameras update method looks like:

    public void Update(Vector3 playerPos, float pitch, float yaw)
        Matrix rotation     = Matrix.CreateRotationY(yaw) * Matrix.CreateRotationX(pitch);
        Vector3 newOffset   = Vector3.Transform(offsetAmount, rotation);

        cameraPos   = playerPos + newOffset;
        View        = Matrix.CreateLookAt(cameraPos, playerPos, Vector3.Up);
        Projection  = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Constants.AspectRatio, Constants.NearClip, Constants.FarClip);

Sounds alot like your Matrices are being multiplied in the wrong order. Try reversing the order of Multiplication to:

Matrix rotation = Matrix.CreateRotationX(pitch) * Matrix.CreateRotationY(yaw);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.