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
3
Question by simes89 · Oct 14, 2015 at 09:52 AM · androidremotecompasssensormagnet

Access Magnetometer Compass values via Unity Remote 4 for Android

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 instead 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'm using Unity 5.2.1f1

I also set the permissions in the start function: void Start() { Input.location.Start(); Input.compass.enabled = true; Input.gyro.enabled = true; } void OnGUI() { GUILayout.Label("rawVector_z: " + Input.compass.rawVector.z); }

Related issues I found:

  • http://answers.unity3d.com/questions/843516/compass-returns-all-zeros.html

  • http://feedback.unity3d.com/suggestions/unity-remote-compass-values

Steps to reproduce it:

  • Create empty GameObject

  • Create C#-Script and attach it to the GameObject

  • Paste the following code: (adjust class name)

using UnityEngine; using System.Collections;

public class getCompassValues : MonoBehaviour {

 public float gyro_value;
 public float compass_value;
 // Use this for initialization
 void Start () {
     Input.location.Start();
     Input.compass.enabled = true;
     Input.gyro.enabled = true;

 }
 
 // Update is called once per frame
 void Update () {
     gyro_value = Input.gyro.rotationRate.y;
     compass_value = Input.compass.rawVector.z;

 }

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

}

  • Get Unity Remote 4 for Android. Enable Unity Remote on your PC via Edit->Project Settings->Editor: Under Unity Remote choose "Any Android Device" in the first row.

  • Connect the Android Device via USB, start the Remote App and press Play.

  • You should see the gyrovalues over the GUI and also over variable in the editor, but the compass value is always zero. Sometimes the gyro value is also 0, then stop and press play again.

Thanks! regards Simon

Comment
Add comment · Show 1
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 Patchbristol · Oct 25, 2016 at 12:01 AM 0
Share

Hello Simon,

How did you get on with this project? I am a 3rd year game sound student and am ai$$anonymous$$g to use compass data in a binaural action game I am creating. It would be great to perhaps get some insight into your progress with this to see if you may be able to offer some help with my compass integration.

Thanks,

Patrick

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Why I can not enable compass (I gave it time to warm-up)? 0 Answers

How do I find out anything about the Unity Remote for Android that is available in Unity 3.2? 1 Answer

Sensor Fusion of Accelerometer and Gyroscope 0 Answers

Android Testing 4 Answers

Mapping Android Media Key Codes To Unity 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