Ball maze android issues


I’m making a basic ball maze for android and have been looking at the c# game example on the asset store. On pc it works fine but my android controls dont seem right…the left/right tilt seems backwrds and forwards/backwards is completely messed up resulting in the ball floating and bobbing around…

I want to be able to tilt the phone and roll the ball around the maze, any help is much appreciated!


using UnityEngine;
using System.Collections;

public class MarbleControl : MonoBehaviour {

    public float movementSpeed = 6.0f;
	void Update () {
        Vector3 movement = (Input.GetAxis("Horizontal") * -Vector3.left * movementSpeed) + (Input.GetAxis("Vertical") * Vector3.forward *movementSpeed);
        rigidbody.AddForce(movement, ForceMode.Force);
		//Android controls
//	controller = GetComponent(CharacterController);		
		Vector3 dir =;  //Android controls - accelorometer
        dir.x = -Input.acceleration.y;
        dir.z = Input.acceleration.x;
//		dir.y = 0;
		//clamp acceleration vector to unit sphere
        if (dir.sqrMagnitude > 1)
        //move at meters/second instead of per frame
        dir *= Time.deltaTime;
        transform.Translate(dir * movementSpeed);
		//move ball
		//controller.Move (dir * movementSpeed);

    void OnTriggerEnter  (Collider other  ) {
        if (other.tag == "Pickup")
            //Other collider.. See other.tag and

I’m not at my workspace right now, but try using gyroscope instead of accelerometer. It might just work. Revert back if it works. I’m on a similar project now and need reviews on the same.