- Home /
Tilt movement with Unity Android
I'm a new Unity/Android user/developer. I've gotten a ball rolling in android using the tilt functionality, but that script doesn't work for a simple box. How would I make a box move by tilting the android device?
Thanks
Comment
Best Answer
Answer by BCouto · Oct 26, 2010 at 03:02 AM
I've figured it out. These lines of code should do the trick for moving an object in a 2d space
function Update () { var dir : Vector3 = Vector3.zero;
dir.x = -Input.acceleration.y*.5;
transform.position.x += dir.x;
}
can you suggest me a good tutorial or reference that related to tilt controls in unity?
@dewdrop i would just look at the prefabs for this. Import mobile assests and you can get the correct ones if you're still interested.