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
1
Question by smtabatabaie · Aug 07, 2012 at 09:25 PM · androidaxisaccelerometer

Accelerometer z axis problem

hi , I'm trying to build a project which uses accelerometer as its input . I created a guitext to debug and see how my Nexus S accelerometer works . I wrote this :


 function Update()
 {
  var phoneX = Input.acceleration.x ;
  var phoneY = Input.acceleration.y ;
  var phoneZ = Input.acceleration.z ;
  
  guiText.text = "phoneX : " + phoneX +
  "\nphoneY : " + phoneY +
  "\nphoneZ : " + phoneZ;
 }

I'm trying to use the z value of accelerometer . I think the axis are y is in direction of phone's height , x in direction of phone's width and z is the vector coming out of screen . but holding the phone parallel to the floor and rotating it around it's z doesn't affect any of the accelerometer's values.


I'll be appreciated if someone can help me with this


thanks

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
2
Best Answer

Answer by aldonaletto · Aug 08, 2012 at 12:45 AM

That's right. The only acceleration constantly acting over the accelerometer is the gravity. With the phone parallel to the floor, the whole gravity is applied opposite to the Z axis direction, thus it should show a value -1 (-1 G) while the other axes should be 0. Slowly rotating it to the upright position will move gravity from Z to the Y axis, and you should get Y = -1 and Z,X = 0 when completely vertical.
Maybe you're confusing accelerometer with gyroscope - a gyroscope can track rotations, while the accelerometer only reports the result of forces acting on the phone - usually fast movements (shaking, hitting, etc.)

Comment
Add comment · Show 3 · 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 smtabatabaie · Aug 08, 2012 at 02:20 AM 0
Share

thanks so much Aldo . the problem I'm facing now is that it seems gyro doesn't work with Android devices and Input.gyro.enabled seems to be always false . I tried to change the gravity with Physics.gravity = Vector3(0,0,1) but it seems that accelerometer works with real gravity not the scene gravity . I'll be appreciated if you've some other idea to make it work . thanks so much

avatar image aldonaletto · Aug 08, 2012 at 12:18 PM 0
Share

Yes, the accelerometer axes are fixed, and Physics.gravity isn't taken into account. About the gyro, this thread ( http://forum.unity3d.com/threads/118786-android-gyroscope-in-unity-3.5-beta ) shows that other people are having problems with Android gyro in Unity - maybe it's not correctly implemented in Unity 3.5 versions yet. Have you tried to set Input.gyro.enabled to true? It seems that it's false by default in Android devices.

avatar image smtabatabaie · Aug 08, 2012 at 02:54 PM 0
Share

thanks Aldo . yes I've tried to set to true but it seems to be always false . there's GyroDroid in asset store , I haven't tested it http://forum.unity3d.com/threads/101279-GyroDroid-2.0-Access-each-and-every-sensor-on-Android-devices-RELASED . thanks again Aldo

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

8 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to find Accelerometer delta value? 1 Answer

3D: how to avoid jerks in a character movement using accelerometer 1 Answer

roll ball in two axis using devices accelerometer. 1 Answer

How do I rotate my player and still make it go where I tilt my phone? 1 Answer

Is it possible to get the forward and backward movement of android device 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