Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

hyper88

Camera in 3rd Person view?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Are there any tutorials or sample codes for a camera to follow an object in 3rd person view? or some explanation will do.......

Share this post


Link to post
Share on other sites
Advertisement
You need to know the position, and the LookAt vector of the object you want to follow.

The math is quite simple, normalise the target objects LookAt vector to get a vector i''ll call ObjLookAt.

Now calculate the cameras position by doing:

CameraPosition = ObjPosition - (DistanceToFollowAt * ObjLookAt);

And set the cameras LookAt vector to

CameraLookAt = ObjPosition - CameraPosition;

This will give you a camera that is always at exactly the same point in space behind the object. To make the camera "flow" you simple introduce variables for WantedCameraPosition and WantedCameraLookAt, and every frame move the Camera Position and LookAt some small amount towards those values.

Good luck,

Alan

Share this post


Link to post
Share on other sites
There is a great article about Mario64 style 3rd person camera & controls in Game Programming Gems 2. I highly recommend it.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!