• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
Question by Ashiash · Nov 14, 2016 at 03:09 PM · androidrotationvrgyroscopegyro

Input.gyro.attitude not working on newer Android devices

Hi guys,

I've written an app for viewing 360° panoramas. The app has a Google Cardboard mode, and a normal mode where you can rotate the camera either using touch input or using the phones/tablets gyroscope. Now this app has been in the stores for a while now and everything was working fine. Both in iOS and Android. But recently more and more Android devices have been popping up, where my code for the camera rotation controlled by the gyroscope doesn't work anymore. The phones in question do have a gyroscope, and frustratingly the Google Cardboard mode works fine. However Googles code is hidden in a dll, so I can't see how they accomplish this.

Here's a code snippet of the camera rotation code:

 // current measurement:
 Quaternion gyroMeasurement = Input.gyro.attitude;
 gyroMeasurement = new Quaternion(-gyroMeasurement.x,-gyroMeasurement.z, -gyroMeasurement.y, gyroMeasurement.w);
 gyroMeasurement = gyroMeasurement * Quaternion.Euler(90, 0, 0);
 Vector3 euler = gyroMeasurement.eulerAngles;
 
 // calculate the delta values between our current measurement and the first measurement. 
 // Update: we only want the offset on the y-axis. The x-axis should be the current gyro measurement. 
 Vector3 finalDeltaValues = new Vector3();
        
 finalDeltaValues.y = euler.y  -m_initialGyroMeasurement.y;
 
 // add the small delta values to the original orientation of the camera.
 float finalEulerValueX = euler.x; 
 float finalEulerValueY = m_currentEulerVec.y + finalDeltaValues.y;
 
 // feed these values into a quaternion and then perform the movement.
 if (bAnimated)
     StartCoroutine(RotateCameraAnimation(transform, transform.rotation, Quaternion.Euler(finalEulerValueX, finalEulerValueY, 0), 0.3f, false));
 else
    transform.rotation = Quaternion.Euler(finalEulerValueX, finalEulerValueY, 0);


In Debug mode I can see that Input.gyro.attitude always returns 0,0,0,1 on these devices. Can anyone point me in the right direction to get this working again? Feel free to contact me if you need any more info.

Cheers, Sebastian

Comment

People who like this

0 Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ashiash · Nov 16, 2016 at 08:41 AM 0
Share

Am I missing something here? How come nobody has answered or commented on this question?!? Not even with a follow up question.

avatar image LK84 · Nov 16, 2016 at 10:03 AM 0
Share

does SystemInfo.supportsGyroscopereturns true on those devices? did you set Input.gyro.enabled = true ?

3 Replies

· Add your reply
  • Sort: 
avatar image

Answer by fake-love · Dec 03, 2016 at 07:41 AM

Hello, My development team was having a similar issue. We would set Input.gyro.enabled = true yet it would return false. I suggest downloading Gyrodroid in the Google Play store and click on Statistics - All Sensors. The phones that were giving me this issue all returned Gyroscope - NO meaning it doesn't exist in my device. In our case we need the gyro specifically as opposed to accelerometer unfortunately.

Comment
ContractorNation

People who like this

1 Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Ashiash · May 15, 2017 at 10:03 AM 0
Share

Ok, thanks for the suggestion. I'll test that on the devices which were giving us problems...

avatar image

Answer by Monstermash28425R1 · Jul 17, 2019 at 02:59 PM

hi, my systeminfo return support gyroscope =>true, but also return a attitude of (0,0,0,1), in fact,its return gyro.gravity with some diferent values, but attitude dont work, beside, u can see a dll with .net reflector windows app

Comment
NoBudget_Studios

People who like this

1 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by Ashiash · Nov 16, 2016 at 10:10 AM

@LK84 Hi LK84,

Yes in both cases. If SystemInfo.supportGyroscope returns false I don't even show the buttons to switch into Gyroscope mode or Google Cardboard mode. But on some newer Android devices the SystemInfo.supportGyroscope returns true. -> I show the buttons. Google Cardboard mode works fine but Input.gyro.attitude doesn't return anything, thus rendering my Gyroscope mode useless (user remains stationary).

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

125 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UNITY 3D - Set the start positon of the gyroscope to initial phone position 1 Answer

Strange android gyrometer attitude angles 1 Answer

Gyroscope not working in Android Build, but it works on Unity Remote? 0 Answers

Move towards VR Camera Orientation with Bluetooth Controller (Android) 0 Answers

How to setup android build so that users without gyroscope do not see it in Play Store ? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges