I want to improve upon my first person camera implementation and extend it to, so the user can toggle between third person/first person view.

My current setup: draw()::


    // Render gameObjects

Camera is strongly coupled to the player, so much so, that it is a friend of player. This is what the Camera::ApplyCameraTransform looks like:

glm::mat4 l_TransformationMatrix;
m_pPlayer->m_pTransformation->GetTransformation(l_TransformationMatrix, false);

l_TransformationMatrix = glm::core::function::matrix::inverse(l_TransformationMatrix);

So, I take the player's transformation matrix and invert it to yield First person camera view.

Since, Third person camera view is just a 'translated' first person view behind the player; what would be a good way to improve upon this (keeping in mind that I will be extending it to Third person camera as well.


  • \$\begingroup\$ it says someone answered, but i can't see the answer. I've tried three different browsers, but it shows up on none ? \$\endgroup\$ Commented Feb 5, 2011 at 6:31
  • \$\begingroup\$ I have this issue as well \$\endgroup\$
    – Ray Dey
    Commented Feb 5, 2011 at 14:09
  • \$\begingroup\$ For posterity, here's a link to the relevant meta discussion: meta.gamedev.stackexchange.com/questions/380/… \$\endgroup\$
    – user1430
    Commented Feb 5, 2011 at 19:05

1 Answer 1


Not entirely sure what kind of improvements you're after here, so I will suggest two different kinds:

  1. I don't see that it's necessary to strongly-couple the camera and the player object, certainly not to the point where they grant friendship. All it seems like you're doing in this example is grabbing the transform of the player, which is something I would expect you could do via the player's public interface -- in fact, I would expect it to be something you could do via a more generalized interface -- any entity with a position. For improved code health, I would suggest decoupling these two.

  2. If the only different between your first-person and third-person camera is a transformation tweak to place the camera behind the target object, I think you'll notice some unpleasantly jerky camera dynamics in response to user input in 3rd person mode. Many 3rd person camera's implement a spring-like system to damp their movements in response to player input (example here), so you might consider implementing damping constraints that you can have applied separately for both camera modes.

  • \$\begingroup\$ Good answer. You also may need to look at raycasting to keep out of terrain. Have a look at this question gamedev.stackexchange.com/questions/10388/… which talks about how complex this issue can get. \$\endgroup\$
    – tenpn
    Commented Mar 31, 2011 at 8:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .