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 /
  • Help Room /
avatar image
4
Question by byurocks23 · Nov 29, 2014 at 09:18 PM · androidinputmobileboocompass

Compass returns all zeros

I have no idea why but my compass does not work no matter what I try. Here is my exact code in boo with almost all of the compass methods being printed to the console.

 import UnityEngine
 
 class Compass (MonoBehaviour): 
     
     def Start ():
         Input.compass.enabled = true
         Input.location.Start()
     
     def Update ():
         rawHeading = Input.compass.rawVector
         trueHeading = Input.compass.trueHeading
         magneticHeading = Input.compass.magneticHeading
         headingAccuracy = Input.compass.headingAccuracy
 
         Debug.Log([rawHeading,trueHeading,magneticHeading,headingAccuracy])

When I run this I get this printed to the console exactly

 [(0.0, 0.0, 0.0), 0, 0, 0]
 UnityEngine.Debug:Log(Object)
 Compass:Update() (at Assets/Compass.boo:15)

I've enabled the compass and started location in the start method, to my understanding, it should work.

My phone is the Droid MAXX, Android version 4.4.4. The compass works on the phone, I've tested through multiple compass apps. There is probably something simple I am missing but I just can't seem to catch it.

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

3 Replies

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

Answer by KMKxJOEY1 · Nov 29, 2014 at 09:26 PM

First off, I commend you on your use of boo, not many people utilize the language within Unity. Next thing is, are you testing this using a build or using the Unity Remote? Unfortunately, when developing mobile applications (at least on android), rotation and whatnot has been dodgy for me. Usually I will just make a build and run logcat to get the debug that I need.

Comment
Add comment · Show 6 · 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 byurocks23 · Nov 29, 2014 at 09:29 PM 0
Share

I am using the remote. I should of already checked if that's the problem, I will now build it to my device and run it there. I'll get back to you when I get the results.

avatar image byurocks23 · Nov 29, 2014 at 09:43 PM 0
Share

Yep it seems to work when I build it to my device. That's going to be annoying building it to my device every time I want to test something. I am using Unity 4.6 and Remote 4. I wonder if that's an error in Unity 4.6 or an error with my phone. Any suggestions on how to fix it?

avatar image Joe_User · Nov 29, 2014 at 09:44 PM 0
Share

Thanks for that answer. I'm about to start work on a project involving Android, and it's good to know about these problems in advance. :)

avatar image KMKxJOEY1 · Nov 29, 2014 at 09:45 PM 0
Share

Ok great! I agree it is annoying, but other than submitting bug reports there is nothing you can really do to fix it (as far as I am aware). Usually what I do is just add extensive debug so that I can get as much data as I can with each build to $$anonymous$$imize wasted time.

avatar image simes89 · Oct 12, 2015 at 03:32 PM 0
Share

The problem still exists, I reported a bug and writing also here. I'm developing for Android and use the Unity Remote 4 App to interact with the sensors and to see the Game-View immediately on the smartphone. I tested with Samsung Galaxy S3 and Google Nexus 5. If i build and run the application, the compass/magentometer values are accessible. But over the Remote-App the magnetometer values are always 0/not accessible. Building the application all the time ins$$anonymous$$d of using the remote function would take too much time. I checked if other sensor values are accessible. The gyroscope data is shown over the remote app. So it seems to be special problem with the compass sensor.

I also set the permissions in the start function: void Start() { Input.location.Start(); Input.compass.enabled = true; Input.gyro.enabled = true; }

To see the values I used:

void OnGUI() { GUILayout.Label("rawVector_z: " + Input.compass.rawVector.z); }

Related issue I found: - http://feedback.unity3d.com/suggestions/unity-remote-compass-values

Show more comments
avatar image
0

Answer by chad47 · Dec 22, 2015 at 09:11 AM

I am having this same problem. I have added ten votes to the issue. If anyone else is having this issue please vote this issue to the top of the list by going to the link that simes89 gave and voting. @byuroccks23 @Joe_User @KMKxJOEY1 @simes89

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 DiegoWw · Jul 11, 2019 at 09:41 AM

Same problem here (but only in Unity Remote, at the device it works). I was able to start the LocationService and get GPS readings, but the Compass still return all zeroes (and -1 as the Timestamp).

PS: For anyone not able to even get GPS to work, first enable Location access for the Unity Remote App on the phone itself, on Android configs. It does not automatically ask for permisson in any way.

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

30 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

Related Questions

Problem with Android platform 0 Answers

How to pick up an object when touching a button(Mobile) 0 Answers

How to check if a player click on a object: Android Mobile 1 Answer

Multiple inputs with one finger on Android? 1 Answer

Integrating compass data - Andoid 0 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