- Home /
Question by
samz · Jul 20, 2013 at 02:26 PM ·
mobileaccelerometertilt
Move if mobile tilts in positive Y direction
how do i move an object via the tilt feature of the mobile but in only one direction, for my case in the positive y. my code does not seem to do this.
function MoveStone()
{
var dir : Vector3 = Vector3.zero;
dir.y = -Input.acceleration.y;
dir *= Time.deltaTime;
// Move object
if( dir.y > 0 )
{
transform.Translate (dir * speed);
}
}
Comment