I have a camera being controlled by an accelerometer. I am aiming to make the camera counter-rotate and stay on the horizon line, while the device tilts left and right. I have a pretty solid system for accomplishing this, however I cannot get the smoothing to work nicely at all. Can anyone point me in the right direction?
var myVelocity : float = 0.0F;
var lookSmoothDamp : float = .3;
function Update () {
var finalAngle = Input.acceleration.x*40*-1;
var cameraRotation = Mathf.SmoothDamp(maincamera.transform.rotation.z, finalAngle, myVelocity, lookSmoothDamp);
if(finalAngle < 20 finalAngle > -20) {
maincamera.transform.localEulerAngles.z = cameraRotation;
}
}