# Rotate an object smoothly by using Accelerometer Input in Unity

There is a simple script where the object orientation is equal to the mobile devices orientation.

it works but the object doesn't rotate smoothly.

void FixedUpdate()
{
float accelx = Input.acceleration.x;

float angle = Mathf.Asin(accelx) * Mathf.Rad2Deg;

transform.eulerAngles = new Vector3(angle , 0, 0);
}


How to rotate an object smoothly by using Accelerometer Input ?

• Accelerometers are inherently noisy sensors that can't reliably distinguish between orientation and accelerating motion. Usually we use sensor-fusion to combine their input with other sensors to get a better-calibrated estimate of our orientation. Have you considered using Input.gyro.attitude instead? – DMGregory Mar 7 at 20:55