Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
1
Question by dumby · May 21, 2014 at 11:35 AM · physicsrigidbodygravity

Rigidbody unwanted drifting

Hi everyone! yet another question on physics stuff...

I've got a simple scene with a cube and a plane. The cube has a box collider and a rigidbody attached while the plane has just a mesh collider attached.

I made a simple script to make the cube slide on the plane, according to user input, that only applies forces to its rigidbody. I used the following code to make it move on its forward direction:

 float vaxis = Input.GetAxis("Vertical");
 rigidbody.AddRelativeForce(speed * vaxis * Vector3.forward); 

Drag and angular drag are set to zero.

Since there are no physic materials attached to any object in the scene and the physics settings are set to default values, I would expect the cube to slide in its forward direction without changing its orientation but this is not what I get. Its rotation params slightly change and the result is that the cube is not moving straight forward, but is following a curved trajectory on the plane that I can not control.

If gravity is disabled on the cube or if I freeze rotation, everything works as expected but this is not a solution in my case. Why is this happening? Am I missing something in the way rigidbody or physics works?

Any help is appreciated!

EDIT -----------

I forgot to mention that I set the cube's rigidbody center of mass to (0, -1, 0) to make the cube slide and not roll...

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
Best Answer

Answer by Noob_Vulcan · May 21, 2014 at 12:06 PM

Yes this effect is very much expected (basic Physics). The friction force is making the cube to rotate. So you have two options

1.Freeze Rotation

2.Add a physics material( set friction to 0 and rest options to minimum) and the material to box collider (i.e cube ).

Comment
Add comment · Show 4 · 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 dumby · May 21, 2014 at 12:50 PM 0
Share

Thank you for your answer, I'll try to play with physic material then...

But still I do not understand where the friction force come from... maybe it is generated from the interaction between the cube's box collider and the plane's mesh collider even if I do not assign any physic material to them.

avatar image Noob_Vulcan · May 22, 2014 at 04:15 AM 0
Share

@dumby Yup u are rite it is generated from the interaction between the cube's box collider and the plane's mesh collider. If my answer helped you then mark it as answer so that if any body else run into same problem then he can refer to this answer. Thank you

avatar image dumby · May 22, 2014 at 07:37 AM 0
Share

Yep. After some other experiments I can say that there is definitely some kind of friction between colliders even if none of them has a physic material assigned. I run into this problem because the docs say:

Friction, bounciness and softness are defined in the Physisc $$anonymous$$aterial.

which is not totally correct as far as I can tell...

Thank you!

avatar image Noob_Vulcan · May 22, 2014 at 09:44 AM 0
Share

Welcome..When ever you add rigidbody to some object physics is applied i.e some friction force starts acting (by default). To make it frictionless u have to add something extra i.e physics material

avatar image
1

Answer by rkatos · Apr 16, 2016 at 08:32 PM

I've run into this problem and yes, setting dynamic friction to 0 stops it, but this is not accurate to the real world.

I also seems the higher the friction the more forceless sliding takes place. Again, opposite to what one would expect!

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 R1P4R14N · Feb 02 at 03:51 AM

This was my problem.

Another solution is to put a rectangular collider on the bottom part of the object so that it doesn't spin. At least that's what worked for me. Yes I realize this is 6 years old but hey if I'm reading it someone else will be too. Good luck!

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

23 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

Related Questions

Movement on a tube 1 Answer

Change Gravity? Physics scaling for large objects to behave like normal ones... 0 Answers

Attaching Rigidbody breaks gravity 1 Answer

Gravitational Object Creation for 3D Game 1 Answer

gravity problem 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