Simple Accelerometer Question

Hey guys,

I have been having problems getting what should be a simple tilt control working.

Basically, the game is in landscape mode, and you play with the screen facing you ( oriented as if you were holding it to a wall, and not on a table ). Like using the iPhone as a steering wheel.

What I want to do is trigger whatever event when you tilt past a certain angle to the left, and trigger a different event when you tilt past an angle to the right, and do nothing if the phone is held level. I don’t need a lot of smoothing or filters as it’s just a simple on or off situation.

Would anyone be able to provide some advice on how to do this properly?

Thanks,
-Jeremy

Have you played around with something like this:

var myTurnInput : float = iPhoneInput.acceleration.y;
if (myTurnInput > 0.2) {
   Debug.Log("Turning Left");
} else if (myTurnInput < -0.2) {
   Debug.Log("Turning Right");
}

You might need to change the signs depending on your game orientation.

That did the trick, thanks a lot!

-Jeremy