Calabrate Accelerometer


Im using this code to rotate and object in my scene.

function Update () {

if (transform.eulerAngles.z <= 10){
transform.eulerAngles.z = 10;
if (transform.eulerAngles.z >= 75){
transform.eulerAngles.z = 75;



I need to calibrate the accelerometer to make game play more comfortable. At the moment I have to have the phone flat which is uncomfortable. I would prefer the phone to sit at about 45 degrees. The project will be landscape orientation.

Any help will be appreciated.

Make a calibration button. Save the Input.acceleration and subtract or add the result from the iphoney variable when you initialize it.

Something like this:

//when calibrating

//when initializing

I’m not remembering if you add or subtract the two numbers. I’m unable to test at the moment.