Desperate for help on control for a ball on android phone.

Hey guys. I’m completely new to unity and this is my first time using it.

I have a maze setup which I would like to roll a ball through.

After hours of searching all night I’ve been using this code which is the only one that finally made my ball move. However it flies off the screen and in all kinds of directions.

I read lots of posts pointing me to different places but I don’t really understand the coding and therefore the explanations are useless to me.

Just wondering if anyone could point out if there is a mistake, I have a deadline coming up and need this completed asap!

Thank you in advance guys!

function Update () {
    var dir : Vector3 = Vector3.zero;
    dir.x = -Input.acceleration.y*.5;
    transform.position.x += dir.x;
    dir.y = -Input.acceleration.x*.5;
    transform.position.y += dir.y;
}

Ok update on this. I’ve changed to try and use this code

// Move object in XZ using accelerometer (home button at right hand)
var speed: float = 2.0f;
function Start(){
}
 
 
function Update(){
var xmovment: float = -Input.acceleration.y;
var zmovment :float = -Input.acceleration.x;
 
Physics.gravity= Vector3(zmovment*5,-15,xmovment*5);

}

However as was said in the same thread the ball gets caught on corners and sides and stops moving. It was said to update it with this code but I’m not sure where it fits in.

function Update(){ if (rigidbody.IsSleeping()){ print("Wake up little Suzy!"); rigidbody.WakeUp(); }

Any help would be great. Thanks guys!