Download

How to get the phone orientation

Hello, I have been developing a android application where I need to get the phone orientation. I have the motion input and get the phone sensor but they need a treatment that I had not found yet. i know that in Android it is so easy because the Android SDK give the final orientation values, where are implicitly the acceleration and gyro values. I want to know how to operate this values to get the phone orientation, either anything like the android values or anything you know about.

Thank you for reading.

I use get player controller -> Get input motion state.

Here is a screen shot of how I set up my game to switch between horizontal and vertical. Only needed the gravity for that.

Thank you Drenmon, but I have tried with that function. The gravity is the accelerometer values and the rotation rate is the gyroscope values. I have tried a lot of thing to get a stable and correct orientation with those values but I have not found anything to operate them. I do not know either the tilt could help or which is the right way to opertate the motion state values for a right orientation.

I had not mention it, I want to get the final pitch, yaw and roll values with the input motion state.

Thank you for reading.

Ignore all the other outputs. Just use the gravity vector output as I have here. It gives you the 3 gyroscope values X (pitch) Y (roll) Z (yaw) as you ask for.

When I was setting mine up I did a print string on gravity, packaged the game as a development build and run on phone to figure out what the values were at different orientations.