Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Emperor · Oct 14, 2016 at 08:35 PM · camerarotationgyroscope

How do you remove jitter from input.gyroscope.attitude?

I have my camera rotation equal to input.gyroscope.attitude in each update. The idea is that the phone orientation is used to orient the game camera like in the real world. The problem is that the camera is way too jittery with this code and needs to be smooth.

I tried doing something like:

Quaternion.Slerp(transform.rotation, new Quaternion(-Input.gyro.attitude.x,-Input.gyro.attitude.y, Input.gyro.attitude.z, Input.gyro.attitude.w), Time.deltaTime * smooth);

But this is still pretty jittery no matter what variable I put as smooth.

What can I do to smooth things out?

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 doublemax · Oct 14, 2016 at 08:44 PM 0
Share

Try a running average. Ins$$anonymous$$d of taking the current attitude value, remember the last 5 (for example) and then take the average of those 5.

avatar image Emperor doublemax · Oct 17, 2016 at 06:40 PM 0
Share

I tried averaging but it is still horrible. I don't know what to do anymore. See my implementation below. I tried increasing the count, I tried with a delay(implementation below, it kinda stabilize it but only because it adds artificial lag), without delay, with slerp, without slerp...Nothing works and I'm Getting really frustrated:

 //quatQueue is a queue of quaternion
 //at each update
  if (quatQueue.Count >= 5)
         {
             quatQueue.Enqueue(Input.gyro.attitude);
             quatQueue.Dequeue();
 
             Vector4 avgr = Vector4.zero;
             Quaternion tempQuat = quatQueue.Peek();
             Quaternion firstQuat = quatQueue.Peek();
             int index = 2;
 
             foreach (Quaternion singleRotation in quatQueue) {
                 $$anonymous$$ath3d.AverageQuaternion(ref avgr, singleRotation, quatQueue.Peek(), quatQueue.Count);
             }
             transform.rotation = Quaternion.Slerp(transform.rotation, new Quaternion(-avgr.x, -avgr.y, avgr.z, avgr.w), 1);
             quatQueue = new Queue<Quaternion>();
         }
         else
         {
             quatQueue.Enqueue(Input.gyro.attitude);
         }             

1 Reply

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

Answer by Emperor · Oct 21, 2016 at 07:13 PM

My problem was not the Gyroscope but instead the large numbers used as position coordinates for the camera. In other words, my camera was at something like x:7000000 y:4000000 and this doesn't work accurately in the Unity Engine. It resulted in a lot of jitter.

If you end up on my question and you don't use large numbers for your position, then slerp, averages, filters are all valid methods of reducing the jitter.

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How to set child position and rotation fixed respect parent? 0 Answers

Why the control with gyroscope inverted when I make 180 degrees turn? 1 Answer

Virtual Reality - Android Gyroscopic Camera - Pitch and Roll Issues. 1 Answer

Gyroscope smooth transitions (minimizing jerk from tiny movements) 1 Answer

Rotate gyroscope-based camera over it's Y axis by swiping 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