# [Solved]Smooth Camera

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

## Recommended Posts

Hi and happy new year,

I want to create a smooth camera for my application like Kodu's camera, any one has any information or idea how can I do that???

indeed my camera works fine but isn't smooth.

Thanks.

##### Share on other sites

I don't know how Kodu's camera works, but my best bet would be to use a lerp with some damping/springiness applied to it.

You are likely to find plenty of examples if you search for "Smooth camera movement using X" where X stands for the language/engine/framework/something you are using.

##### Share on other sites
Smooth hm, sounds like you may want to use slerping for rotation, and lerping for movement. I've never looked at Kudo's camera, but thats what I would do if I wanted to smooth anything.

##### Share on other sites

but my best bet would be to use a lerp with some damping/springiness applied to it.

Thanks Rld_ I tried to use Lerp but I couldn't get acceptable smoothness.

##### Share on other sites

I don't know about Kodu's camera system. However, linear interpolation gives smoothness between key values, but it does not do so when key values are crossed. You need to use another interpolation scheme. Which exactly depends on which kind and degree of smoothness you want. There are 2 (not mutual exclusive) types: Geometric continuity Gn and parametric continuity Cn

G0 means that the the segments on both sides of a key just join; G1 means that they join and their tangents are equal in direction; if both tangents are also equal in magnitude then they are C1 continuous; if the direction and magnitude are equal in the n-th derivative then they are Cn continuous.

So why all this? Lerp gives you G0 / C0 continuity. But you don't want the direction change, so you want at least G1 continuity. Is this sufficient? Probably not, because if you don't have C1 continuity, the position of the camera is smooth but its speed is not. Further, if you don't have C2 continuity the acceleration of the camera will not be smooth when crossing key values.

That said, there are some parametric cubic curves / splines that may do what you want. Hermite and Bezier splines both have C0 / G0 continuity, so they are smooth inside their span but jump as Lerp does when going to the next span. Catmull-Rom and Kochanek-Bartels splines both have  C1 / G1 continuity. And both uniform and non-uniform B-splines have C2 / G2 continuity.

##### Share on other sites

Thanks haegarr ,very nice but it is very theortical .

##### Share on other sites

Thanks haegarr ,very nice but it is very theortical .

Well, I don't know how you are currently doing things, so a concrete answer requires more details...

What I meant so far is that if you do interpolation on the fly, i.e. you have not continuous animation paths at hand but just supporting points, then the smoothness depends on the interpolation function you use. There are many interpolation functions out there. So far you seem to use a linear polynomial. That has problems at the supporting points because although the position is continuous when crossing the point, the orientation (and other parameters) has not. Using another interpolation function like the said splines (which are essentially cubic polynomials) does suiting the problem better, depending on the type of spline.

The above suggestion is based on the fact in a previous post linear interpolation was mentioned and you have tried it with no satisfactorily success. If your problem is related to something else, then please tell us.

##### Share on other sites

Let me give you more detail, I have a strategic camera that look from a distance above of a terrain, by holding mouse button and moving the mouse camera can move toward x and z, because of discontinuity in reading mouse position the camera movement will be discontinuity.

##### Share on other sites

Has the camera approximately pass through all the intermediate support points drawn by the mouse sampling? E.g. if you "draw" a right angles gesture with the mouse, should the camera move more-or-less right angled, too, or should it move in a wide arc, or should it move from its own current position immediately to the position marked by the mouse (i.e. ignoring intermediate support points because they are obsoleted), ever with a smooth motion in mind, of course?

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 15
• 20
• 20
• 11
• 9