I have been working to adapt the Roll-a-Ball tutorial to use accelerometer input. I first tried:
float moveHorizontal = Input.acceleration.x;
float moveVertical = -Input.acceleration.y;
Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rb.AddForce (movement * speed2);
The issue is if the phone is flat, the ball rolls forward.
Then I tried:
Vector3 movement = new Vector3 (Input.acceleration.x, 0.0f, Input.acceleration.y);
rb.AddForce (movement * speed2);
And it works perfect!
Why can’t I assign the Input.acceleration to float first, like in my first code snippet?
Mike