Rotate object with accelerometer?

| | August 10, 2015

I’m making a game where you control a platform with balls falling ontop of it, and you have to balance the balls and prevent them from falling off. I’m currently using a mouse to control it with this code:

transform.rotation.eulerAngles.z+=Input.GetAxisRaw("Mouse X");
transform.rotation.eulerAngles.x+=Input.GetAxisRaw("Mouse Y");

I’m trying to make this an Android app, and want to use motion controls so I can tilt the device, as if it were the platform. I figured I would use the accelerometer for this, but I’m not sure. Any ideas on how to do this?


Leave a Reply