D4rWiNS
D4rWiNS

Reputation: 2615

Gyroscope android in a easy way

I am developing a game that need to detect if the device is moving up or down to move up the character or move down, for that I am using gyroscope( If there is a better way please correct me)

But the gyroscope is very complicated for me( since I dont understand so much of phisyc) so I dont know how to detect if the device is movin up or down with the data that It give to me,

How I can detect it with these values?

float axisX = event.values[0];
float axisY = event.values[1];
float axisZ = event.values[2];

Upvotes: 0

Views: 936

Answers (1)

J j
J j

Reputation: 301

The gyroscope doesn't detect motion but rotation, so if you'd like to know if the device is being turned up or down, you can do this with the gyroscope. Which axis is relevant for you depends on if your app is in horizontal or portrait mode. For landscape a positive y means turning up and a negative y means turning down. In portrait a negative x means up and a positive x down.

Upvotes: 1

Related Questions