I am using this code to move an object with the accelerometer:
var dir : Vector3 = Vector3.zero;
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;
dir = dir * 3;
if(dir.sqrMagnitude > 1)
{
dir.Normalize();
}
filter = Vector3.Lerp(filter, dir, 7*Time.deltaTime);
dir = filter * Time.deltaTime;
transform.Translate(dir * speed);
I want a calibrate button so the player doesn’t have to hold the phone parallel to the ground. I just don’t know what I actually need to do in order to calibrate it.