- Home /
Constant Input.Accelerometer Updater for Mobile?
Is there a way to constantly check/update the rotation of a phone based on accelerometer input? I'm able to achieve tilting a phone left/right to get the player to move left/right. But it only works correctly when my phone is laying face up. The moment I switch my real-life phone orientation to being straight up, the tilting doesn't work, and if I lay down (phone face down), then the tilting gets inverted. This all makes sense with my current setup. I could obviously change the values (axes) and get the tilting to work correctly for any one real-world phone orientation (sitting up, laying back, etc).
What I'm wondering is if there's a way to gradually fade between those different phone orientation axis values so that the tilting always works correctly, even if a person changes their body's orientation mid-game.
Thanks for the help! C# appreciated!
look, the acelerometer measure acceleration, if you are on stayed position the main acceleration of the device is gravity, present in all known planets :)
so, in fact, think the output of the accelerometer like a vector pointing straight down the device, if you give it horizontal rotation (so, on the real life horizon, not matter object orientation) the vector don't change its value.
to detect horizontal rotation you can use the gyroscope, (I dont know if now all the devices have one, four years ago, the last time I try a augmented reality game, only few devices had this), or, you can combine the accelerometer with the compass, to get the horizontal rotation use the compass, for everithing else accelerometer, but, the compass have a lack of precission, sensiblity to vibrations... that made me gave up that time.