2

I want to control something in my game with the Accelerometers sensor.

I don't know why but the getAzimuth doesnt works it always got the value 0, I made this test by showing the result of some methods and this is the output

Sample of Code :

font.draw(batch, "Gdx.input.getAccelerometerX() : " + String.valueOf(Gdx.input.getAccelerometerX()), 10, 200);

The output :

Gdx.input.getAccelerometerX() : -8.245
Gdx.input.getAccelerometerY() : 0.457
Gdx.input.getAccelerometerZ() : 1.245

Gdx.input.getAzimuth() : 0
Gdx.input.getPitch() : 0
Gdx.input.getRoll() : 0

Other problem :

getAccelerometerX(), etc, works but even when the phone is lay on a table those numbers always changes

LeSam
  • 1,235
  • 4
  • 18
  • 38

2 Answers2

4

Your device either doesn't have a compass, or you have disabled the compass in your AndroidApplicationConfiguration. In either of those cases getAzimuth(), getPitch(), and getRoll() will return 0.

nEx.Software
  • 6,782
  • 1
  • 26
  • 34
  • Ok, but I didn't really get what is difference between getAccelerometerX() and getAzimuth(), What is difference between the compass and the accelerometer, I don't get it. – LeSam Oct 31 '13 at 21:34
  • 2
    Accelerometer measures gravity acceleration, while the azimuth is the angle between the magnetic north and another arbitrary point. – Dr. Spam Oct 31 '13 at 22:17
1

The accelerometer values show the device orientation to the ground. The azimuth according to geographical orientation (meaning magnetic north etc).