Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am attempting to implement a sort of, smooth camera that has angle offsets from the player as they turn, creating a cinematic effect as well as visual feedback for when the player turns.

Here is an example of the desired functionality. (Starts at 1:06) http://youtu.be/uJ6tD-k_RuA?t=1m6s

One idea I was thinking of (if even feasible) is to store a "desired quaternion" of orientation of where the camera wants to look (preferably the player's quaternion of orientation) and a "current quaternion" of the cameras orientation and SLERP to the desired quaternion. Then possibly set a max angle between the two rotations to cap how large the angle offset could be.

What are the ways of doing that?

share|improve this question
2  
For dynamic animation situations like this I like to draw what the interactions look like; for you this is between plane orientation, future orientation, current and relative camera locations and desired camera target. Until you have a clear understanding of how those all work together you're just shooting in the dark and hoping to hit something. So use screen captures from the linked video, draw in the orientations and targets, and use that to decode what they're doing behind the scenes and then create your tech. –  Patrick Hughes May 12 '12 at 22:59

1 Answer 1

Quite old thread I see... :) Maybe somebody else will need that.

When I needed similar solution I tried hard with camera parented with the player object and quaternion tricks as you said, etc. and nothing seemed to work as I wanted. Then, I detached my camera from the player and everything became easier.

Just detach your camera and compute some point at the back of your player - this will be the point that you camera wants to get into. For every frame just move your camera by some percent of the distance to the target - this way you get nice, smooth movement.

The same applies to rotation - make some "target" orientation, it may point to the player, or in the same direction the player looks, and for each frame compute some percent of rotation difference to get closer to your target value.

In fact, what you want is some kind of chasing camera. It's not physically connected to the player but it tries to follow him smoothly. When you put your camera as a players child, then it inherits all player transformations, so it starts looking as if it was connected. You get the situation like on some GoPro movies, with camera attached to your helmet and pointing at your face. Then, you try to find some clever math to avoid the effect of your own hierarchy :).

BTW: Remember about your frame rate and numerical integration errors - i.e don't compute like: val = dist * 0.1f, but val = dist * log(speed,time)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.