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 ocarson · Jul 13, 2011 at 04:06 PM · androidaccelerometertablet

Can unity get the native orientation of an android device?

Hi everyone. This is a follow on question from :

answers.unity3d.com/questions/142961/android-accelerometer-inputacceleration-linked-to.html

It seems that the source of my original problem is that android tablets, and android phones have different native orientations of the accelerometer in relation to the screen.

please see the diagram at the bottom of this page.

http://developer.nvidia.com/content/android-tablets-are-here

in short.

landscape tablets see x and y accelerometer readings differently.

they see y as up/down from a landscape position. this would be x on a phone.

How can I detect this?

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by almo · Jul 13, 2011 at 04:13 PM

I think you could do it like Tilt 2 Live, a game on iPhone which supports different orientations.

Have a "calibrate" screen where it asks the user to hold the device as he will while playing. Read the data that comes in, and set that as the neutral orientation. Maybe add a snap to certain axes or angles (like 45, 60 or 90).

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 ocarson · Jul 13, 2011 at 04:23 PM 0
Share

Thanks for the prompt reply almo. This is probably the route I'll go down, however hopefully unity can support this kind of thing in the future, rather then having to work around it.

Does anyone have a definitive answer on if this is possible or not?

avatar image almo · Jul 13, 2011 at 05:07 PM 2
Share

I think it's not a Unity problem. It's whether or not Android devices will tell you what their "default" orientation is.

avatar image
0

Answer by ocarson · Jul 22, 2011 at 02:42 PM

I've had to revisit this problem.

There is a way to detect the default orientation of an android device in the sdk, and automatically adjust the accelerometer values as outlined in this blogpost on the android blog.

http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html

Now it doesn't look like Unity allows me access to this data without writing a plugin. Surely something so simple should be implemented in the Screen class? Like Screen.defaultOrientation or Screen.autoAdjustAccellerometer?

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 almo · Jul 22, 2011 at 02:45 PM 0
Share

Add it to the feature request list. http://feedback.unity3d.com/forums/15792-unity

avatar image
0

Answer by Billboard · Nov 15, 2012 at 10:06 AM

There's a solution courtesy of Ralph Barbagallo using Unity's access to AndroidJavaClass - see Detecting Android Tablets and Phones in Unity3D

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting Accelerometer Frequency on Android 0 Answers

accelerometer speed 1 Answer

Player Movement when phone shakes 0 Answers

Accelerometer axis differences on Android and iOS? 1 Answer

android phone vs tablet question 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