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 /
  • Help Room /
avatar image
2
Question by ENDAS_ORIGINAL · Aug 06, 2018 at 01:52 PM · rotationinputgyroscope

How to use phone gyroscope as steering wheel?

Hello, I am trying to control transform's rotation with Z axis of phone gyroscope. I have tried it using gyro.rotationRateUnbiased.z which in theory worked fine but after few tilts of device, rotation of device wasn't synchronized with gameobejct's rot. so probably there was some drift happening... Then I tried rotating transform using gyro.attitude.z but that only worked properly when my phone was oriented to north (because the attitude is based on compass, gyroscope and accelerometer (there is not much about it in documentation so I guess that's how it is working...)) When my device was oriented randomly (not to north) Z axis was mixed with X and Y. I have tried to measure gyroscope offset from north at start of program and then decrementing measured value from current gyro attitude value in runtime but z axis was still mixed with x and y. I have read probably all of the threads on internet about gyroscopes/accelerometers in unity and problems associated but nothing really worked for me :( So if anyone has experience with what I mentioned here, please give me your advice or if there is any plugin or something for this I would be really thankful for mentioning it:) Thanks a lot for every response.

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by ENDAS_ORIGINAL · Aug 11, 2018 at 11:41 AM

Finally I noticed gyro.gravity property and that works fine :)

 void Rotation() {
         float gravityOutputMultiplier = -50; 
         Vector3 currentRot = transform.eulerAngles;
         transform.eulerAngles = new Vector3 (currentRot.x, currentRot.y, gyro.gravity.x * gravityOutputMultiplier);
 }

Also gyro.gravity in my case uses both accelerometer and gyroscope probably for better accuracy I guess, but the output is still a little shaky so I suggest to process it with moving avarage of last 3-7 output values to make it more stable

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 mandy1339 · Aug 05, 2020 at 10:26 PM 1
Share

Wow, this is exactly what I needed to just detect steering type of tilt. I don't know how this is not in the other most visible posts about this topic. Thanks!

avatar image
0

Answer by narlankaaditya · Apr 29, 2021 at 08:08 AM

@ENDAS_ORIGINAL will this script make my steering wheel rotate as much as I tilt my phone?

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 ENDAS_ORIGINAL · May 31, 2021 at 01:13 PM 0
Share

Yes, maybe adjust the multiplier(sensitivity) value a little if the steering wheel is turning faster or slower than the phone. It is also possible that the change in gyro.gravity.x is not directly proportional to change of phone's tilt in degrees but you can fix that with goniometric math functions. And obviously you have to assign the new Vector3 value to correct transform also u have to call this function from Update() and declare and assign your gyro probably in Start().

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

195 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Android - Gyroscope - When I hold still it, the camera continues to rotate 1 Answer

Rotate camera like VR on mobile 3 Answers

Gyro Rotation Offest Calculation or Alternate Solution? 1 Answer

To change 2 quaternions based on 1 input 0 Answers

Does Input.acceleration use gyroscope? 2 Answers


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