0
votes

someone can tell me how can I reset my accelerometer. I have a 3D environment, and my ball bounce left-right correctly, my Y is ok, I don't need it, but my z is not ok, I use my device in landscape mode. Pratically when my devide is 90° (landscape mode) with the floor is in neutral z position. I need to have neutral position when user start game, I see other answer on unity blog with they don't work for me. This is my code :

public float posZ;

// Use this for initialization
void Start () {
    Salvataggio.control.Load ();
    posZ = Input.acceleration.z;

}

void Update () {

    trovaPallina = GameObject.FindGameObjectWithTag ("Pallina");

        if (trovaPallina) {
            trovaPallina.transform.position += new Vector3(Input.acceleration.x / 10, 0, (Input.acceleration.z - posZ) / 10) ;
        }

}

1
What exactly is wrong with your current setup?Samy Bencherif
What is the question/problem?Hristo

1 Answers

0
votes

Why not create some sort of calibration for it? So, you could create a calibration menu in which you click a button once you are satisfied with the zero position of the device. Store the x, y & z values as your zero values. That way, you can use the current values against your zero values to determine the offset in each direction.