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 Exuro89 · Jul 31, 2016 at 06:51 PM · physicsrigidbodytorque

Spinning a sphere in place causes unwanted velocity.

Hello,

I'm playing around with moving a sphere using rigidbody physics. Right now I have the sphere and floor set up with physics materials and am tweaking them to get a good balance of traction as well as sliding/spinning depending on how fast the sphere is moving. The sphere is being controlled with the AddTorque function, and I'm having some issues when it loses traction/spins/slides on the floor. So I'm moving forwards and backwards and when I switch from one to the other the floor's friction isn't high enough so the sphere spins which i what I want, however there's velocity/force being added to the left/right for some reason. Here's a video showing what I'm experiencing.

https://www.youtube.com/watch?v=whcu9Kmgajc&feature=youtu.be

Can someone explain what it is that is happening? I'm only applying torque to move forward and backward but when it slides it moves left and right. I'm having trouble determining why it's doing 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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by smnerat · Jul 31, 2016 at 11:10 PM

I think your sphere is moving sideways because there is a lot more going on than it appears at first glance. From a physics standpoint, there are a lot of non-linearity's associated with friction, especially when an object has enough torque to overcome static friction and move into dynamic friction, which is what happens when your sphere begins to spin when changing directions. Without getting into the nitty-gritty, a ton of crazy things can happen in this situation.

I'm not familiar with the inner workings of PhysX or how Unity uses it, so anything from here on is speculation. Your sphere isn't perfect, its made up of about 1500 vertices, so as your ball rolls you will have a different amount of vertices contacting the ground at any given time, and the forces applied to your sphere by the ground are ever so slightly different. Eventually, the small amount of instability adds up, along with what I mentioned in the above paragraph, and the final result is your sphere sways to one side or the other.

So my guess is that the physics engine is much more accurate than most people realize, someone with a better understanding of PhysX and Unity could tell you for sure.

A quick solution would be to freeze your rigid body's position in the swaying direction. Check if your input direction is the same as your rigid body's. If they're different, constrain your rigid body, otherwise, don't constrain.

     private Rigidbody rBody;
     private RigidbodyConstraints rc;
 
     void Update () {
 
         Vector3 travelDirection = rBody.velocity;
         Vector3 inputDirection = Vector3.back;
 
         if (travelDirection.z > 0 && inputDirection.z < 0) {
             rc = RigidbodyConstraints.FreezePositionX;
             rBody.constraints = rc;
         } else {
             rc = RigidbodyConstraints.None;
             rBody.constraints = rc;
         }
     }
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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Returning a rigidbody back to its original x and z rotations through physics forces. 2 Answers

Physic Torque Hinge joint problem 0 Answers

AddTorque not increasing relativeVelocity magnitude of a collision 1 Answer

Rigidbody rotation with PID controller and torque 0 Answers

Constant Force doesn't work 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