• 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 Iguanodon · Sep 09, 2016 at 04:22 PM · vrrotate objectaccelerometermobile devicesgyroscope

Getting X axis input from accelerometer when mobile device is held upright?

Hi all! I'm developing a mobile game with a gyroscopic, VR-style camera, which rotates to face wherever the player is pointing their device. I've got this up and running the way I want it with devices containing a gyroscope sensor (so Apple devices are behaving nicely), however I ideally would like this game to be available to Android users, and I'm aware that most current Android devices do not have gyroscope sensors.

What I've been trying to do in light of this is make an accelerometer-controlled camera which achieves a gyroscopic-like effect. I've been able to achieve good results along the camera's x axis using accelerometer input, so the camera nods up and down as the player tilts the device in a very similar way to a gyroscopic camera. However, I've hit a wall as I'm trying to now implement movement along the camera's y axis when the player tilts the device left and right.

The problem is that when the device is held upright, so that the screen is directly in front of the player's face, and is then tilted from side to side, I notice that the input vector3 from the accelerometer does not change significantly. The same is also true when the device is lying flat and being rotated in a circle like a steering wheel.

What I wanted to know is if there is any way I can rotate the camera along its y axis according to the side to side rotation of the device when it is held upright, or is the lack of input from the accelerometer in this scenario just an inherent limitation of accelerometers?

I've attached some diagrams on what I'm trying to achieve and my script, if anyone has any suggestions and/or knows what is and isn't possible with an accelerometer, I would be very appreciative :)

 void Update()
     {
         transform.rotation = Quaternion.LookRotation(new Vector3(-Input.acceleration.y, Input.acceleration.z, -Input.acceleration.x));
 
     }


[1]: /storage/temp/77924-unity-diagram.png

unity-diagram.png (69.0 kB)
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 WoerlaGames · Sep 09, 2020 at 07:42 AM 0
Share

It's been 4 years and no answer.

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Smellogaming · Aug 29, 2018 at 02:21 PM

It's been 2 years and no answer.

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 R3fr4ct0r · Sep 19, 2019 at 07:56 PM

It's been 3 years and no answer.

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 WoerlaGames · Sep 09, 2020 at 07:45 AM

It's been 4 years and no answer.

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 escfoe2 · Apr 17 at 11:52 AM

Coming on 6 years no answer. Guess I'll give it a go. The Accelerometer measures acceleration by using tiny springs and essentially measuring the force applied to them, whereas a gyroscope uses a spinning gyro to measure the changes to the gyro over time.

Since accelerometers measure acceleration, they also measure the force of gravity (9.8m/s^2). Any axis parallel to the gravitational pull of the earth, when moved, will show almost no effect. It's an unfortunate limitation of accelerometers.

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

7 People are following this question.

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

Related Questions

How can I get the movement when a mobile device moves parallel to the ground? 2 Answers

accelerometer video 0 Answers

How to calibrate the mobile gyroscope ? 1 Answer

How to use an IMU with Unity? 1 Answer

inertial navigation system plugin 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