# 3rd person camera math help

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

## Recommended Posts

Hello, I am trying to get a third person camera working, I have been refering to tonnes of articles and threads on the topics but I just can't get the smooth turning math working, so I was hoping if I posted my specific situation somebody could give me a hand. What I am aiming for: Positioning: Behind the character but offset by an arbitrary (x,y,z) and an arbitrary pitch (p) kind of like how it is in Gears of War where the player is offset to the side of the screen. Behavior: Forward vectors of camera and character need to match so the camera is looking in the same direction as the player. I would like some lag in the movement so when you turn for example the camera rotates smoothly preferably a spring system, currently this is my biggest problem if I just set the camera forward equal to the player forward when you turn it is way to fast and disorienting but I can't get it to interpolate properly. The same problem with positioning if the player makes essentially a 90degree turn the camera shouldn't just cut across the shortest path to position itself i should do gradual turn. I have been trying to solve this by using a VELOCITY based approach but something is missing. I am working in a framework so the function I have access to is structured like this Vector3 Camera.Position Matrix3x3 Camera.Rotation ( Camera.Rotation.Axis(0) is the forward ) Vector3 Player.Position Matrix3x3 Player.Rotation void Update(float deltaTime) { //Get desired camera values by applying offsets to current player values //Figure out new camera values by interpolating from current to desired Camera.Position = newPosition Camera.Rotation = newRotation } Thank you

##### Share on other sites
http://www.gamedev.net/community/forums/topic.asp?topic_id=427197&whichpage=1%EF%BF%BD

have a look at the 5th post

##### Share on other sites
Although the camera in that example does move smoothly, it isn't quite what I am looking for

The camera in the example is always trying to look at the player from directly behind; I am trying to make a camera that is always looking parallel to the player's forward vector from a position behind and to the side, i.e. directly behind the players shoulder.... I am trying to mod the example to give that affect but I am not having any luck

##### Share on other sites
If you know the players position as a starting point, and you know the players various directions (forward, right, up) offset from the players position to the point you want to be looking at. Some quick vector math for example
position + (right * horizontalOffset) + (up * verticalOffset) would give you a point to the right and above the players position to look at, try making that your target point to look at, then make sure the camera swings quickly behind horizontally about the up axis, then make sure the vertical or pitch angle is correct so its looking parallel with the characters direction and not pitching up or down about the side vector.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633708
• Total Posts
3013474
×