Game Development Community

Accelerometer Tilt Issues

by Ahmed Murad Akhter · in iTorque 2D · 09/21/2009 (2:12 pm) · 6 replies

Hi,
There is a bug I've noted with using the joystick to implement the accelerometer. After the values reach minus one, tilting the device further along that axis actually increases the value. Since I'm including an option for the user to specify a neutral point, I get some undesirable behavior.

When the neutral point is specified with the device held almost vertically (yaxis = -1), the character can't move down since tilting further downwards increases the axis value.

Has anyone else noticed this and if so is there some solution to the problem.

Regards

#1
10/18/2009 (3:24 am)
Hey,
This seems to have gone unnoticed... Can somebody please reply as it seems a significant issue.

Regards
#2
10/18/2009 (11:04 am)
Sven can probably comment better on this, but I'm thinking that soundss like a "feature" of the iPhone hardware and not a bug in iTBG.

It's up to you as a developer to find out the ranges and values returned by the hardware in given circumstances and then handle those results as necessary for your app.

All you have to do is play with the orientation in something like Safari or that gravity teapot sample app to see how borky the iPhone accelerometer actually is.
#3
10/18/2009 (3:39 pm)
I should have said there's a limitation rather than a bug. Anyway, is there a way to work around this?
#4
10/18/2009 (9:42 pm)
Its neither.
The iphone does not measure angles or tilt or anything, it measures the direction of the gravity which on earth is "down to core"

For that reason, to get usefull ways to handle it, you need to use vector math and trigonometrics
#5
10/19/2009 (3:15 am)
Are the values returned by iTGB (when treating the accelerometer as a joystick) the unit vectors in x y z direction then?
#6
10/19/2009 (4:02 am)
You may look inside the script files of the behavior components demo, there inside behaviors/input/shooterControls.cs you can see that :

Quote:
//-Mat iPhone accelerometer is mapped to to joystick0

With a little investigation in the scripts, i can see that a Joystick to script has the xAxis, yAxis and zAxis values that you can echo to the output and see what you are getting back. There is also xVal and other values attached to the joystick but im sure the axis is all you need.

You can also look inside /behaviors/input/alignToJoystick.cs