Assigning input.acceleration to float then adding to a Vector3 to AddForce C#

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

There should be no problem storing the value before creating your movement vector with it. Is this difference due to the fact that you have a negative Input.acceleration.y in the first example, and a positive Input.acceleration.y in the 2nd?