# simple camera prob

This topic is 5475 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey everyone This is my first post here :) I'm no good at math so you most certainly know more about this than me :( okay I'm trying to take two moving objects and place the camera at the exact center of both of them -20 units on the z axis and still be able to see both objects through the camera at all times i know there is a simple solution to this! but i thought maybe you might be able to give me some advice on this thanks for your help

##### Share on other sites
well find the distance between them divide that by two and place thats the center position....but then again you might have to bring the camera back so that you can see both objects as they move away from each other

##### Share on other sites
Vector Up(0, 1, 0);Vector Centre = (Obj2.Pos + Obj1.Pos) / 2;Vector Extent = (Obj2.Pos - Obj1.Pos) / 2;Vector Dir    = Extent.Cross(Up);Dir.Normalise();float e  = Extent.Magnitude();distance = e / tan(DegreesToRadians(Camera.FiendOfViewAngle / 2));Camera.Position  = Centre + Dir * distance;Camera.Direction = -Dir;Camera.Up        = Up;

thank you :)

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 13
• 14
• 40
• 63