Jump to content
• Advertisement

#### Archived

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

# Camera in 3rd Person view?

This topic is 5941 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

##### 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

##### Share on other sites
It gets more complicated when you want it to interact with the world geometry though.

#### Share this 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

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
2. 2
Rutin
19
3. 3
khawk
19
4. 4
5. 5
A4L
11
• Advertisement

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633771
• Total Posts
3013762
×

## Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!