accelerometer not working unity

why is the cube moving when I use a controller, but not with the accelerometer?

void Update () {
text.text = "X: " + Input.acceleration.x + "; Z: " + Input.acceleration.z;
//transform.position = new Vector3(10* Input.acceleration.y, 0, 10* Input.acceleration.z);

transform.Translate(Input.acceleration.x, 0, Input.acceleration.z);

//transform.position = new Vector3(10* Input.GetAxis("Horizontal"), 0, 10* Input.GetAxis("Vertical"));

transform.Translate(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
}


(I'm on a Xperia Z3 compact by the way)

I guess you might need to apply some speed so that it works on the phone. Might be the Input.acceleration.x value is not high enough on phone, but works on the controller. Also it is advisable to use Time.deltaTime to keep the speed constant on all device, else it will change as per the device processing power.

 public float speed = 10.0f;
void Update ()
{
transform.Translate(Input.acceleration.x*speed*Time.deltaTime, 0, Input.acceleration.z*speed*Time.deltaTime);

}

• Suddenly it works for some reason O.o (without modification) - what about "transform.position = 'vector3 from accelerometer'" though?
– user67808
Aug 15 '15 at 21:05
• That will not move it beyond a particular distance as the values from accelerometer will reach a threshold. Try using += on individual axis so that it moves. Aug 15 '15 at 21:09
• I wanted it to not move further than a particular threshhold, so the position mirrored the orientation of the device. Like when Input.accelerometer.x is at 0.7 the transform.position.x should be 0.7 * 10
– user67808
Aug 15 '15 at 21:20