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 kloudon716 · Feb 15, 2016 at 10:05 AM · androidcollisionaccelerometer

Accelerometer Axis inverting after collision

Hello all, here is a breakdown of my issue. The game is a 2d top down ball hitting objects game built for Android. Accelerometer controls work fine, however after several minutes of play the axis of the accelerometer controls will invert. I believe that it is linked to collisions where the ball bounces back away from an enemy that it collided with. Additional notes: the controls will work again at the start of the next level, it is an issue that occurs during play. I have tried resetting the control axis on collision, or every frame, even adding in the low-pass and other filters suggested on forums, but this just made the issue more profound (kept low-pass cause it made motion more realistic). This is built and tested using Unity 5.3.2f . The issue has occurred on multiple devices both with remote and as release build. In addition it does not happen with any one enemy nor is it related to their masses as I have tested extensively attempting to remove the issue for nearly 2 weeks. Below is the code used in the controls.

     /*here is the snippet for the controls, this is in FixedUpdate function /and as stated works, it is an issue that occurs during gameplay and I have been unsuccssessful in tracking it down other than the bounce back may be causing the flip flop of the axis.    */    
                        curAc = Vector3.zero;
             LowPassFilterAccelerometer();
             curAc = new Vector3(lowPass.x, lowPass.y, 0f);
             if(curAc.sqrMagnitude >1){
                 curAc.Normalize();
             }
             curAc *= Time.fixedDeltaTime;
             transform.Translate(curAc*speed); 
 
         }
     }
 //This is the low pass filter, which works fine.
     void LowPassFilterAccelerometer(){
         lowPass = Vector3.Lerp(lowPass, Input.acceleration, filterFact);
     
     }
 //this is the reset that was added to the OnCollisionEnter.
     void ResetAxes(){
         curAc = Vector3.zero;
     }

Any help would be greatly appreciated.

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
0

Answer by kloudon716 · Apr 03, 2016 at 10:21 PM

In case anyone else runs into this, the issue is caused by the collision causing a 3D rotation in the z axis, despite all colliders being 2d. To remove the issue on the player's Rigidbody 2d -> constraints check to turn on z-rotation (there should be a check in the box). This will stop the axis from rotating with the accelerometer inputs as the player can no longer rotate in z.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Trigger collision not detected if player is stationary 1 Answer

Check accelerometer's rotation Android 2 Answers

Problem with Vectrosity line colliders 0 Answers

How do I access CoreMotion and the Android equivalent? 0 Answers

how to hang a 3d model hanging seamlessly from a camera 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