I can use the following code to rotate object using accelerometer.
transform.rotation = Quaternion.LookRotation(Input.acceleration.normalized, Vector3.up);
But i would like to rotate object like for example screen is rotating - 0, 90, 180 and 360 degrees. How can I do it using Unity 3D?
You can use
transform.rotation
like this:OR
You can use
transform.Rotate
like this:Documentation for Quaternion
Documentation for transform.rotation
Example for Rotating screen with accelerometer input:
If you want to rotate the object to a specific angle use:
This will rotate 90 degrees around the x axis.