- Home /
How to get the value of the an angle of the Gyroscope?
I'm trying to get the value of the angle of my phone's gyroscope (and then I print it on a text on the screen) but I'm not able to do it. For what I've understood, I have to use a quaternion so how can I get the value of an angle of the gyro let's say for example in the y axis?
Answer by Cobra117 · Jul 08, 2019 at 02:04 PM
I finally found how to do it! Once you've understound it's very simple you just get the values (all the axis) in the quaternion and then get a value into a float so you can get a specific axis, for now this not angle, this is value the seem to go from 0 to 1 (or -1 if depending in which you turn the phone) it shouldn't be very hard to get angle now.
So in void update:
//my quaternion
Ry = new Quaternion(gyroV.attitude.x, gyroV.attitude.y, gyroV.attitude.z, gyroV.attitude.w);
//my float that get the value of the z axis
RotationY = Ry.z;
Your answer
Follow this Question
Related Questions
3rd player orientation using gyro with offset 0 Answers
Calibration Script 0 Answers
3D camera relatively using gyro a la N.O.V.A. 2 0 Answers