Set a point for the accelerometer

I’m using the accelerometer at the moment, every time i test, I hold my device at roughly a 45 degree angle which sends the object flying as soon as i open the app.

I’m assuming i receive this reaction as it’s expecting the device to be flat, but sometimes if the object goes too far up, i’d nearly have to turn my device over on it’s back to get the object back down which obviously is not an ideal situation as I can’t see the screen.

I find it hard to word this but is there a way I can change the accelerometer settings so that i can use, for example the 45 degree angle i’m going to hold it at as the center point? I’d like the accelerometer to start at the position that I’m holding my device when the app starts.

I calibrated when the scene started to fix that. Unfortunately I can’t find a way too detect when the device is inverted. Which seems to also invert the two input axis.

using UnityEngine;
using System.Collections;

public class Calibrated : MonoBehaviour {

	//calabrations for tilt
	private float xCalabrate;
	private float yCalabrate;

	void Start () {
		xCalabrate = Input.acceleration.x;
		yCalabrate = Input.acceleration.y;
	// Update is called once per frame
	void Update () {
		if (MainControler.control.SetGyro () && Input.acceleration != default(Vector3)) {
					float tempX = Input.acceleration.x - xCalabrate;
					float tempY = Input.acceleration.y - yCalabrate;

I’ve got a same problem and I thank you for your answer, but … that is a “MainControler”? If I use your code, my program wrote Error (Does not exist).
Sorry I’m a newbie.