Camera in 3rd Person view?

Started by
2 comments, last by hyper88 21 years, 7 months ago
Are there any tutorials or sample codes for a camera to follow an object in 3rd person view? or some explanation will do.......
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
"There will come a time when you believe everything is finished. That will be the beginning." -Louis L'Amour
It gets more complicated when you want it to interact with the world geometry though.
There is a great article about Mario64 style 3rd person camera & controls in Game Programming Gems 2. I highly recommend it.

This topic is closed to new replies.

Advertisement