Input Acceleration low-cut + smooth

I’m trying to rotate my camera based on the Input.acceleration.y.
The usual Problem is that the acceleration values are not smooth and very sloppy.

So i tried to low-cut and smooth the acceleration.
Here is what i tried.

That does not work proper, but i cant find out what to do to get it working.

float newrotation = 0;
float tmp = Input.acceleration.y;
if(Input.acceleration.y >= lastacceleration.y + 0.05 ||Input.acceleration.y <= lastacceleration.y -0.05)
	tmp = Input.acceleration.y;
	tmp = Mathf.Lerp(lastacceleration.y , tmp,Time.deltaTime *20);// tmp
tmp = lastacceleration.y;				
newrotation =  tmp *90f;

lastacceleration = Input.acceleration;

camerago.transform.localRotation = Quaternion.Euler( 0,0,newrotation);

if you want a less-sensitive accelerometer then i suggest you save the Input.acceleration into a variable and divide it by a certain number to vritually smoothen it’s sensitivity, then use this variable instead of the real Input.acceleration.

Hope i helped



If you’re looking for smoother steps concerning your acceleration, you can interpolate them using Mathf.Lerp

link to reference :