- Home /
Question by
Eco-Editor · Mar 28, 2019 at 01:59 PM ·
c#androidscenegyroscopeupside-down
Why gyro on Android displays upside down?
Hello all,
I have a gyro script I found here: https://www.youtube.com/watch?v=P5JxTfCAOXo this is the script: using UnityEngine;
public class GyroControl : MonoBehaviour {
private bool gyroenabled;
private Gyroscope gyro;
private GameObject cameraContainer;
private Quaternion rot;
private void Start()
{
cameraContainer = new GameObject("Camera Container");
cameraContainer.transform.position = transform.position;
transform.SetParent(cameraContainer.transform);
gyroenabled = EnableGyro();
}
private bool EnableGyro()
{
if (SystemInfo.supportsGyroscope)
{
gyro = Input.gyro;
gyro.enabled = true;
cameraContainer.transform.rotation = Quaternion.Euler(90f, 90f, 0f); // adjust rotation angle on tablet
rot = new Quaternion(0,0,1,0);
return true;
}
return false;
}
private void Update()
{
if (gyroenabled)
{
transform.localRotation= gyro.attitude;
}
}
}
My issue is that the when in play mode the scene looks correct. When I open the scene with Unity remote or build and run, the scene is upside down.
Why is this happening?
Comment