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
0
Question by $$anonymous$$ · Aug 15, 2015 at 07:26 PM · androidaccelerometer

accelerometer not working

Hi,

why is the cube moving when I use a controller, but not with the accelerometer?

 void Update () {
     text.text = "X: " + Input.acceleration.x + "; Z: " + Input.acceleration.z;
     //transform.position = new Vector3(10* Input.acceleration.y, 0, 10* Input.acceleration.z);

     transform.Translate(Input.acceleration.x, 0, Input.acceleration.z);


     //transform.position = new Vector3(10* Input.GetAxis("Horizontal"), 0, 10* Input.GetAxis("Vertical"));

     transform.Translate(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));
 }

(I'm on a Xperia Z3 compact by the way)

Comment
Add comment · Show 3
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 Runalotski · Aug 16, 2015 at 09:21 PM 0
Share

Try adding a Debug.Log("X accel : " + Input.acceleration.x + " Y : accel" + Input.acceleration.z)

at the end of the block as it should return a maximum of one so the actual number will be smaller like 0.2 or something

Try multiplaying the accerlation by 20 and see if it moves if not try 100 if it still dosent work then i am not too sure.

avatar image Paximillian · Aug 16, 2015 at 11:37 PM 0
Share

Well, I know that the Gyro is actually disabled by default and needs to be enabled first before use(Input.Gyro.enabled = true), it wouldn't surprise me if you had to have it enabled for Input.acceleration to work too, even though it's not in the Gyro class for some reason. (http://docs.unity3d.com/ScriptReference/Gyroscope-enabled.html)

I'm not sure if this is the case or not, and don't have the ability to set up a test project for my phone at the moment, but you might want to give it a shot and tell us how it went.

avatar image Vals_k9 · Apr 30, 2016 at 11:09 PM 0
Share

@$$anonymous$$, @Runalotski , im having the same problem with my xperia z3 compact. It was working fine the night before, but this morning, the phone decided the screen would not auto rotate. Ive gone into the normal settings and switched auto rotate on and off several times, ive restarted the phone, and just did a factory reset,ive ran the diagnostic tests too. but nothing. Ive now investigated deeper and found that by typing ##7378423## into the keypad, it gets me into some settings i didnt know existed.

Gyroscope is working, but the accelerometer is not.

these are the readings i get from the settings:

X: -38.0792 Y: -38.9015 Z: 39.2839

I have no idea what they are supposed to be, i assume these readings are off and they should be something else.

I really dont know much about coding on an android and have not dared to do anything involving the Root thing.

Any help would be appreciated to fix this. i cant even take pictures because they appear upside down or sideways, even if the camera button is facing the right way up?

Look forward to receiving any help possible..

Val,@$$anonymous$$, @Runalotski , im having the same problem with my xperia z3 compact. It was working fine the night before, but this morning, the phone decided the screen would not auto rotate. Ive gone into the normal settings and switched auto rotate on and off several times, ive restarted the phone, and just did a factory reset,ive ran the diagnostic tests too. but nothing. Ive now investigated deeper and found that by typing ##7378423## into the keypad, it gets me into some settings i didnt know existed.

Gyroscope is working, but the accelerometer is not.

these are the readings i get from the settings:

X: -38.0792 Y: -38.9015 Z: 39.2839

I have no idea what they are supposed to be, i assume these readings are off and they should be something else.

I really dont know much about coding on an android and have not dared to do anything involving the Root thing.

Any help would be appreciated to fix this. i cant even take pictures because they appear upside down or sideways, even if the camera button is facing the right way up?

Look forward to receiving any help possible..

Val

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

26 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

Related Questions

Accelerometer Axis inverting after collision 1 Answer

how to convert Input.mousePosition into iphone/android accelerometer? 1 Answer

activate animation on android device rotation 0 Answers

Acelerometer Controlled Racing Game For Android 1 Answer

Camera linked directly to device orientation 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