- Home /
Question by
RishiSh · Jul 29, 2014 at 07:58 PM ·
inputaccelerationtilt
Tilting the Player Object while moving it with Input.acceleration
My game involves moving a plane through a field of obstacles by tilting the phone left and right. Right now, I'm using input.acceleration to make the object move. I'd like the plane to tilt (bank) while it moves, but i'm having difficulty. Any help would be appreciated. So far I have this code to move the player:
Vector3 dir = Vector3.zero;
dir.x = Input.acceleration.x;
if (dir.sqrMagnitude > 1) {
dir.Normalize ();
}
transform.Translate (dir speed Time.deltaTime);
Comment