I think i have a "should be" working code but i don't know why it is not working. With this code too i have to hold the phone straight to get it to work. My present code is below.
Any help is appreciated :)
#pragma strict
var speed : float;
var accelerationX : float = 0;
var accelerationZ : float = 0;
var zatstart : float = 0;
function Start () {
zatstart = Input.acceleration.z;
}
function Update () {
var dir : float;
dir = (Input.acceleration.z-zatstart);
if (dir > 1){
dir = 1;
}
accelerationX = Input.acceleration.x;
accelerationZ = -1*(dir);
GetComponent.().AddRelativeForce(new Vector3(accelerationX * speed,0,accelerationZ * speed));
}
↧