Gyroscope Samsung S7 doesn't work properly
Here attached a video of Samsung S7 Gyroscope vs Xiaomi MI5 where it shows that Samsungs' Gyroscope doesn't work as it should. it is the only gyroscope I tested where fails. Any ideas how to fix this?
https://www.youtube.com/watch?v=kDGN4Rvw858&feature=youtu.be
This is the script I'm using at the moment... I'd appreciate if there's any mistake at it, please notify.
Thanks for your attention
using UnityEngine; using System.Collections; using UnityEngine.UI;
public class GyroCamera : MonoBehaviour { private float initialYAngle = 0f; private float appliedGyroYAngle = 0f; private float calibrationYAngle = 0f; public Text gyroText;
void Start()
{
#if UNITY_EDITOR
enabled= false;
#else
Input.gyro.enabled = true;
#endif
}
void Update()
{
ApplyGyroRotation();
ApplyCalibration();
gyroText.text= Input.gyro.attitude.eulerAngles.ToString();
}
public void CalibrateYAngle()
{
calibrationYAngle = appliedGyroYAngle - initialYAngle; // Offsets the y angle in case it wasn't 0 at edit time.
}
void ApplyGyroRotation()
{
transform.rotation = Input.gyro.attitude;
transform.Rotate( 0f, 0f, 180f, Space.Self ); // Swap "handedness" of quaternion from gyro.
transform.Rotate( 90f, 180f, 0f, Space.World ); // Rotate to make sense as a camera pointing out the back of your device.
appliedGyroYAngle = transform.eulerAngles.y; // Save the angle around y axis for use in calibration.
}
void ApplyCalibration()
{
transform.Rotate( 0f, -calibrationYAngle, 0f, Space.World ); // Rotates y angle back however much it deviated when calibrationYAngle was saved.
}
}
Answer by Melontxo88 · Feb 16, 2017 at 12:48 PM
We use the values of the gyro of google cardboard.
Answer by arjanwiegel · Feb 16, 2017 at 12:27 PM
We have the same experience here. It looks like the gyro that unity catches is just the accelerometer, without the sensor fusion with the gyro that usually goes on in the background. Many Samsung devices don't even give any value to the unity Input.gyro.attitude member at all...
This is especially a pitty because the S6 and S7 have a very nice low-latency gyro / accelerometer / magnetometer for the gear-VR add-on.
Haven't found a solution for this yet. Google cardboard and youtube app don't seem to have any trouble getting the gyro, so I assume a third party plugin like gyrodroid might do the job.
Answer by nicoDeloitte · Apr 12, 2017 at 09:34 PM
Any solutions for this? We are having the same issue with both the S6 and the S7.
Tried Gyrodroid's but same behaviour :S.
Help! :)
Answer by Tom-Goethals · May 02, 2017 at 12:42 PM
same issue! unity 5.6.0f3 [EDIT] resolved after rebooting the phone
Your answer
Follow this Question
Related Questions
Unity C# Android Gyro - Wrong Orientation 2 Answers
android camera rotation using gyro sensor 1 Answer
Screenshot on Android 2 Answers