Accelerometer Question

I’ve been banging my head against the wall on this for most of the day and after much googling and experimenting I think there’s a major bug/flaw in the accelerometer. I figured I’d post here first since I’m so close to the problem I may just be overlooking something. To make myself as clear as possible, I’ve added visual aids!

It appears that the accelerometer actually only work on 2 axis instead of 3. The X and Z access appear to be an offset of each other. Here’s what I’ve found:

figure 1 - phone laying flat

Accelerometer reading in x,y,z - (0.0, 0.0, -1.0)

figure 2 - phone on its side

Accelerometer reading in x,y, z - (-1.0, 0.0, 0.0)

This doesn’t make sense… only one of these values should have changed - not both the X and the Z. But the really broken part happens next:

figure 3 - rotated on its side

Accelerometer reading in x,y,z - (-1.0, 0.0, 0.0)

The problem here, obviously, is that I’m not picking up the X rotation at all. Is this a bug or am I missing something here?

The accelerometer tells you what portion of gravity is pulling in which axes; it’s not about rotation. You need a gyro for that. I don’t see anything wrong with what you have above, unless it’s a different side facing the ground in the last two shots; you didn’t indicate if it was, but I don’t think you understand what the accelerometer is telling you, considering you didn’t think the second shot was right. It ought to be Vector3.right or -Vector3.right.

Hey Jessy, thanks for the reply. I guess I’m not grasping the concept because from fig 2 and fig 3 the phone has been rotated on it’s X axis and nothing changed value wise from Input.accelerometer. I don’t see how I can rotate the phone and not get some form of acceleration reading.

Gravity is pulling in the same direction, relative to the phone. Dangling a weight from the phone may help you visualize this, but just imagining a line pointing to the floor should do.

Thanks Jessy. Appreciate the help. Since Android doesn’t have a gyro and there’s no native compass call in Unity I’ll have to write a plug-in to pull off what I’m after.