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 /
  • Help Room /
avatar image
0
Question by Mosy · Aug 27, 2015 at 10:59 PM · accelerometerrotation axis

Accelerometer & Rotation

Ok so I'm trying to make a game which uses the accelerometer and rotation to control a game object. I am having a problem with the rotation though. I'm using C# for all of my coding. First I started out by putting the value from Input.acceleration into a Vector3:

 Vector3 thisRotation = new Vector3 (Input.acceleration.y * 100, 0, Input.acceleration.x * 100);

I'm attempting to keep the object from rotating in the Y axis, and my current method is actually working quite well in that regard, and I am also trying to control the object in a top down landscape view. When I put Input.acceration.x into the x, and y into the z it actually showed me that the values were not what I was expecting. That is the reason why I set up that line of code the way I did.

Inorder to get my game object to rotate I am using this line of code with thisGameObject representing the game object I want to apply the rotations to.

 thisGameObject.transform.rotation = Quaternion.Slerp(thisGameObject.transform.rotation, Quaternion.Euler(thisGameObject.transform.rotation.x + thisRotation.x,
                                                                  thisGameObject.transform.rotation.y + thisRotation.y, thisGameObject.transform.rotation.z + thisRotation.z), Time.fixedDeltaTime);

My problem is that the game object is rotating in the opposite direction in the X and Z axes. I have tried to change the application of the 100 modifier in the input section to a -100, and I tried multiplying the rotations by -1 in the rotating line of code. Regardless of what I do though it seems to be rotating opposite of what is the desired effect. For reference my game is locked in a right side up landscape view. Also when I tried to use the Rotate function the game object would just continue to rotate. These lines of code are happening inside of the FixedUpdate function.

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 Mosy · Aug 28, 2015 at 07:21 PM 0
Share

Still looking for help on this issue.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Martians135 · Jun 16, 2017 at 05:09 AM

May be this asset can helps: You can use this asset to Do the rotation. You can use the accelerometer like a gyroscope , this works on all phones, because all devices have accelerometer. And works on all axes. Here this asset:

https://www.assetstore.unity3d.com/en/#!/content/87609

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

27 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 avatar image

Related Questions

Camera rotation in maze game depending of accelerometer 0 Answers

Acceleration and accelerometer calibration 0 Answers

Does Input.acceleration use gyroscope? 2 Answers

Rotatearound with the path 0 Answers

How to rotate a cube vertically when the axis is unknown 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