Damp natural camera sway without a script - Is this possible?

Hi everybody,

Does anybody know whether there’ are components or something similar that can be used to “damp” movement of a transform, i.e. without having to script that “damping” by hand?

Here’s what I am trying to do:

I have a camera attached to my player model for generating the 1st person view.
I’ve explicitely attached it to one of the bones to get immersive “camera sway”.

This works very good. However, the sway is quite strong, as it translates 1:1 from the bone movement. So I want to reduce it a bit to get a more realistic, smoother feeling. Unfortunately, there’s no bone in my model that behaves exactly the way that would match my expectations for the camera (there’s no “camera bone”, of course :)). And I wouldn’t want to start changing my bone animations only for that, because that would restrict animations too much only for the purpose of getting a smoother camera.

I know that I could possibly solve this problem by some scipting, using functions like Mathf.SmoothDamp() etc. But I expect this to become quite complex, and I’d prefer not to rely on too heavy scripting for such a specific need.

That’s why I am looking for a more light-weight solution (if one exists).

I’ve already tried to experiment with rigidbodies, but to no success.

Thanks alot!!

You could try to make your camera read the position and rotation from where it is now, but not actually be a child transform.

Something like this:

class DampedTransform (MonoBehaviour):

    public target as Transform
    public tightness = 1f

    def Update ():
        transform.position = Vector3.Lerp(target.position, transform.position, Mathf.Pow(0.98f, Time.deltaTime * 60f * tightness))
        transform.rotation = Quaternion.Slerp(target.rotation, transform.rotation, Mathf.Pow(0.98f, Time.deltaTime * 60f * tightness))