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 /
This question was closed Sep 07, 2011 at 01:46 AM by Talimar for the following reason:

I fixed it myself. Unity doesn't provide access to the data.

avatar image
0
Question by Talimar · Aug 17, 2011 at 09:33 AM · androidgyroscopegyro

Android gyroscope

Ok, I just started using Unity Android mistakingly believing that Input.gyro would get me data from the gyroscope on a Galaxy Tab, but it doesn't.

I found this post

http://answers.unity3d.com/questions/43794/compass-java-plugin-for-unity-android.html

but the majority of the information is old and links don't exist. I managed to rewrite the java so it would compile, but it crashes on the device, but I never see gyro data before the crash. I notice someone in that thread said they had crashing and managed to solve it by signing the jar file (I'm a total java n00b), I have no idea how to do this. I'm not even sure if I'm exporting the jar file correctly, though Unity doesn't complain.

I'd really appreciate any help anyone can offer. I need the gyro data or my game idea goes out the window.

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 ikriz · May 05, 2012 at 04:06 PM 0
Share

These days Input.gyro is supported still cant figure out how to get live orientation though. Is Input.gyro.attitude.eulerAngles worth using?

3 Replies

  • Sort: 
avatar image
1
Best Answer

Answer by Talimar · Aug 23, 2011 at 01:10 AM

Going to answer my own question here. It involves Java and the AndroidJNI/AndroidJavaClass in Unity.

http://randomactsofdev.wordpress.com

Joshua has it mostly right here, but I think his C# code is fault, in that if you try to call the constructor it will crash, as there is no constructor, and you should not instantiate classes every frame, cache them. Lastly, you need to use the generic methods for float to access the static fields (and note, you must use static fields, instance ones don't seem to work for me).

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
1

Answer by fherbst · Sep 06, 2011 at 04:07 PM

For Android, you could also use a plugin by prefrontal cortex which is available in the asset store. It provides access to all Android sensors.

Demo application (type into your mobile browser to install): goo.gl/oLkOQ

Forum link: goo.gl/8ZIM7

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 Talimar · Sep 07, 2011 at 01:45 AM 0
Share

Thanks, but I wasn't looking for a paid plugin. I ended up getting access via java anyway. I'm suprised I forgot to update this post.

avatar image
0

Answer by CHPedersen · Aug 17, 2011 at 09:59 AM

The Galaxy Tab has an accelerometer, not a gyroscope. Is that what you want? You can access its values through Input.acceleration, see documentation:

http://unity3d.com/support/documentation/Manual/Input.html

That should tell you how the device is oriented. Will that do for your game idea?

EDIT:

My bad about the galaxy tab; I can't confirm it doesn't have a gyroscope, so it might. It just seems Input.gyro is for Unity iOS only, and not for Android. There's a link to another question that states this here:

http://answers.unity3d.com/questions/153383/unity-34-gyroscope-support-not-there.html

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 Talimar · Aug 17, 2011 at 10:34 AM 0
Share

Ugh, I wrote a lot and this website kicked up an error, told me to correct it and wiped everything I wrote. $$anonymous$$oving to a comment also eats posts. Awful forum software this is. Let me try this again.

As far as I am aware, the tab has all the sensors. Compasses work and the gyroscope test work, and the android sdk virtual device says hw.gyroscope: yes. Also this says it has one: http://www.gsmarena.com/samsung_p1000_galaxy_tab-3370.php

Regardless though, I may be jumping the gun. I should have done a simple java class test first, as Im now finding I can't even read a simple hardcoded value from it. For some reason I thought AndroidJavaClass would be able to interface, but even though Unity doesn't complain, I don't think it's going to be that simple (forgetting the fact I've been working on this and other related issues for 12 hours now).

I wont be able to do a C++ plugin because I can't afford Unity Pro. I'm a 100% java n00b as of today, so I'm going to have to learn some more of that and do some trials there.

$$anonymous$$y game idea requires that I can sense movement of the player, not just the orientation of the device. I believe I can do this with a combination of the accelerometer and gyro.gravity.

avatar image CHPedersen · Aug 18, 2011 at 08:54 AM 0
Share

Oooh, I see. $$anonymous$$y bad, I updated my answer with a link to another question with more information. (I saw you participated in the other question yourself, so this is just in case somebody stumbles over this during a search)

Follow this Question

Answers Answers and Comments

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

How should I interpret the gyro's information? 0 Answers

Input.gyro.attitude not working on newer Android devices 3 Answers

Strange android gyrometer attitude angles 1 Answer

Input.gyro.attitude returns zero values when tested with Moto G 4th generation device 2 Answers

I would like to know if with a unity free is possible to use gyroscope android? 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