I am making game , and i have implementd tilt controls for it it works but the problem is that when game starts my player is by default drraging to right direction without any tilt…here is code that i am writing plz help me thanzz in advance
var dir: Vector3 = Vector3.zero;
dir.x = Input.acceleration.x;
if (dir.sqrMagnitude < 0.5)
{
var speed = 10f;
function Update() {
var dir: Vector3 = Vector3.zero;
dir.x = Input.acceleration.x;
if (mathf.abs(dir) > 0.5)
transform.Translate(dir*Time.deltaTime*speed);//Time.deltaTime is the time between frames and it keeps the movement the same even when the frame changes.
}