Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Tweeted twitter.com/StackGameDev/status/782018469441236992
Various minor language clarifications.
Source Link
Anko
  • 13.5k
  • 10
  • 56
  • 82

Rotate In Unity on Android, how can I rotate an object with the accelerometer?

I'm making a game where you control a platform with balls falling ontop ofon 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+=Inputz += Input.GetAxisRaw("Mouse X");
transform.rotation.eulerAngles.x+=Inputx += 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 in Unity?

Thanks, -Chris

Rotate object with accelerometer?

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?

Thanks, -Chris

In Unity on Android, how can I rotate an object with the accelerometer?

I'm making a game where you control a platform with balls falling on 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. 

Any ideas on how to do this in Unity?

Source Link
Chris
  • 59
  • 1
  • 3
  • 4

Rotate object with accelerometer?

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?

Thanks, -Chris