I’m trying to figure out how to use the phone’s tilt to control an object. So far I have a project set up with a simple cube that I want to translate around the scene using transform.Translate. Here’s my script:
void Update () {
Vector3 dir = Vector3.zero;
dir.x = -Input.acceleration.x * 0.5f;
transform.Translate (dir);
}
I wanted to keep it simple first, testing out the x axis only. However, I find that when I set my phone down on a flat surface, the cube starts to move off the screen anyways, even when I’m not tilting the phone in any way. I have to tilt in the opposite direction to keep it steady. Why is this?