I’m just finished the rolling ball tutorial in the getting started guides:
I wanted to run it on my android device. I thought I’d try to use the gyroscope to control the ball motion, but I can’t seem to find any good examples of this in code. Could anyone talk me through how that would go?
right now what I ahve looks like this:
void doMovement() {
float moveHorizontal;
float moveVertical;
if(Input.gyro.enabled) {
Gyroscope gyro = Input.gyro;
moveHorizontal = gyro.gravity.x;
moveVertical = gyro.gravity.y;
} else {
moveHorizontal = Input.GetAxis ("Horizontal");
moveVertical = Input.GetAxis ("Vertical");
}
Vector3 movement = new Vector3(moveHorizontal,0.0f,moveVertical);
rigidbody.AddForce (movement*speed*Time.deltaTime);
}
But I don’t really understand how to debug Unity on android, and I can’t really tell whats happening (or if this is even the right way to approach the problem).