Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • 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 Olpus · Nov 08, 2018 at 05:01 PM · googlegyroscopesamsunggyro

Gyroscope behaving differently between Samsung and Google Pixel

I wanted to control the camera with the gyroscope of Unity and I saw the code on another post here on how to do that. But the behaviour is different between the Google Pixel and Samsung S7 I have to test the app. It seems that the same scene with the same code is flipped about 180 degrees along one of the axis.

 using System.Collections;
 using System.Collections.Generic;
 using JetBrains.Annotations;
 using UnityEngine;
 
 public class GyroControl : MonoBehaviour {
 
     private bool gyroEnabled;
     private Gyroscope gyroscope;
 
     private GameObject cameraContainer;
     private Quaternion rotation;
 
     void Start () {
 
         cameraContainer = new GameObject ("Camera Container");
         cameraContainer.transform.position = transform.position;
         transform.SetParent (cameraContainer.transform);
         
         Screen.sleepTimeout = SleepTimeout.NeverSleep;
         
         gyroEnabled = EnableGyro ();
         
     }
 
     private bool EnableGyro() {
         if (SystemInfo.supportsGyroscope) {
             gyroscope = Input.gyro;
             gyroscope.enabled = true;
             
             cameraContainer.transform.rotation = Quaternion.Euler (90.0f, 0.0f, 0.0f);
             rotation = new Quaternion (0, 0, 1, 0);
 
             return true;
         }
         
         return false;
     }
     
     void Update () {
         if (gyroEnabled) {
             transform.localRotation = gyroscope.attitude * rotation;
         }
 
     }
 }
 
Comment
Add comment · Show 3
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 kolboch · Nov 08, 2018 at 10:02 PM 0
Share

Tell me if I am wrong, you ask just about the state after init right ?

avatar image Olpus kolboch · Nov 09, 2018 at 10:19 AM 0
Share

I'm wondering what is different between the phones. They rotate differently, the models are opposite to each other when building the same app. Don't know if it's the value of the rotation or the quaternion euler of the camera container.

avatar image kolboch Olpus · Nov 09, 2018 at 10:37 AM 0
Share

Just read somewhere that gyroscope values range might be different for different devices. In such case you would have to know such range and normalize 'i guess attitude' it before applying rotation to object / camera.

0 Replies

· Add your reply
  • Sort: 

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.

Follow this Question

Answers Answers and Comments

96 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

Related Questions

External gyroscope question 1 Answer

Google cardboard android build & run 1 Answer

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

Input.Gyro + samsung s10+ = fliped orientation 0 Answers

Windows Phone 8 & Gyro 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