Game Development Community

Setting camera at offset to player

by SaurabhTorne · in Torque Game Engine · 04/02/2006 (11:29 am) · 2 replies

How do I set Camera offset to the player at a certain distance. Say to the right site parallel to the axis

#1
04/02/2006 (4:06 pm)
If you are creating a new player model, the 'eye' and 'cam' nodes set the location of the camera in relation to the model.

If you are wanting to adjust the existing camera position I'm pretty sure you'll have to do a little source code modification, or modify an existing 'advanced camera' resource. The camera.cc and player.cc are good places to start looking around.

B--
#2
04/02/2006 (6:21 pm)
Like an over the shoulder camera?

Adding this into the getCameraParameters function for the player will let you set an x offset from the third person camera
MatrixF mat;
   Point3F rightVec;
   getEyeTransform(&mat);
   mat.getColumn(0, &rightVec);
   rightVec *= mDataBlock->cameraXOffset;

   *off += (rightVec);
That is, assuming you add a datablock value to the player called cameraXOffset, or whatever you want to use. This'll look straight ahead though, you'll need to modify the camera's orientation to get it to look at a point ahead of you, but it's not hard to do that either, especially with the Advance Camera setup for third person.