• 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
0
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
Add comment · 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
1

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
Add comment · 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
1

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
Add comment · 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
0

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
Add comment · 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

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Android Gyroscope inaccuracy problems. 1 Answer

Android: how do i make the rotation of my player follow the rotation of my phone 1 Answer

Change Gyroscope forward 1 Answer

3D camera relatively using gyro a la N.O.V.A. 2 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges