Hi, I have a platform game that uses the accelerometer to move left and right. I’d like to add a feature were the screen rotates opposite to the accelerometer so that the camera is always in the original position, so the scene doesn’t move with the rotation.
Of course that assumes your camera is looking down the Z axis.
Note that the above code combines the Y and Z accelerometer axis to consider what is the vertical component, which lets you play in a wider range of possible holding-the-device orientations.
The code above essentially gives you a variable low-pass filter (look that term up) that smooths out the high-frequency jitter that comes in via accelerometer.
“accumulatedAngle” is the variable name I chose for the filter’s one single state cell. It’s about the simplest low-pass filter you can create.