Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 EricNumeri4D · Mar 05, 2014 at 04:58 PM · c#augmented realitycamera rotationcompass

AR Camera Rotation without gyroscope

Hello,

First, I'm sorry if my english is not very good, I'm french !

The code below come from Heyworks Unity Studio and thanks to the GyroController.unitypackage which helped me a lot with gyroscope.

Summary :

Unity 4.3.4f - C# Galaxy Tab 2 (model GT-P5110) without gyroscope Trying to rotate the camera using the compass (and anything else) on the 3 axis or 2 at the minimum (up/down & right/left).

In details :

I'm developper on Unity (in C# currently) and programming an AR application. So the application is working on the tablet with gyroscope but i have to adapt it for the tablets without gyroscope. On my Galaxy Tab 2 (GT-P5110) there is no gyroscope.

How can I rotate the camera in the 3 axis just with the compass (and any other tool if necessary) ?

I'm trying only with Compass like this :

 m_camAR.transform.rotation = Quaternion.Euler(Input.compass.rawVector.y, -Input.compass.rawVector.x, 0);

This code let me turn on the up/down and right/left axis but only until I reach some values. These values are approximatively 316-317° and 43-44°, after that, the camera rotation is very strange, it goes up when i'm going to the left, etc...

I'm not very good at maths...so please forgive me if it's very simple ! Here is a screenshot when looking to the north, a little bit lower.

alt text

As you can see in the box, there is the rotation of camera and the rawVector of the compass.

So I'm searching a method to update that position which could accept the 360° rotation with that rawVector (or anything else) but without using gyroscope.

I read a lot of articles and answers and codes but didn't find the solution. It is possible because i found an app on the Play Store "3D Compass" which works (but in java).

I'm on Unity 4.3.4f.

Thanks a lot for all answers.

ar_camera_forward[1].png (126.3 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ejpaari · Mar 06, 2014 at 01:42 PM

I would suggest using true heading instead of raw vector so you can get a simple compass heading in degrees relative to north point. Something like this:

 transform.rotation = Quaternion.Euler(0, -Input.compass.trueHeading, 0);

Nevertheless switching gyro to compass could be somewhat bad idea, because compass is not as precise or fast as gyro. Instead you could try to take advantage of accelerometer (there is a plugin for that as well: https://www.assetstore.unity3d.com/#/content/1754).

Comment
Add comment · Show 2 · 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 EricNumeri4D · Mar 06, 2014 at 03:38 PM 0
Share

Hello,

Thanks for your answer, yes I know it's not a good idea to use compass ins$$anonymous$$d of gyro, but without gyro, I've no choice.

What you suggest is working to rotate left/right, I know it and i'll keep it if I don't find any other solution (or I'll lock the AR functionality).

Thanks for the asset, I'll watch it.

avatar image ejpaari · Mar 07, 2014 at 07:57 AM 0
Share

I'm glad I could help. If you think it answers to your question, you should mark it as "Answer" by clicking the little v-sign.

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

22 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

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Mathf.pingpong 4 Answers

Rewriting script from JavaScript to C# 1 Answer

Center camera to an object programatically 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