Search Unity

Sphere continues to roll on sloped surface

Discussion in 'Physics' started by rbOthree, Aug 28, 2017.

  1. rbOthree

    rbOthree

    Joined:
    Oct 16, 2010
    Posts:
    67
    Hi,

    I realise there are many posts referencing a similar problem, and I have tried many of those solutions. Unfortunately I can't seem to get any of them working. Instead of resurrecting an old thread I thought I'd try and start one a little more targeted.

    My setup is as follows:

    A sloped surface with a physics material applied, in contact with a sphere (sphere collider and rigid body) with a physics material applied.

    Things I have tried:

    - Increasing drag. Seems to affect every aspect of the sphere (including moving freely through space), this looks unnatural. Still never makes the ball stop rolling, just makes everything slower.

    - Increasing angular drag. This doesn't seem to have any affect on the sphere. Despite this being one of the most commonly referenced answers, I have tried setting it to a stupidly high amount (10^6) it still continues to roll.

    - Applying negative velocity and applying negative torque. Acts same as angular drag.

    - Forcing sleep (rigidbody.sleep()) when below a certain velocity. Looks extremely unnatural and doesn't have that natural slow down at all.

    - Friction (setting all dynamic/static friction to 1f). I realise sphere/planes have minimal contact, but just in case I set this high. No real effect but it does reach minimum velocity quickly.

    For anything that requires force manipulations I am doing it in the method onCollisionStay.


    I can try and upload a scene if someone is interested in checking it out or if anyone has any ideas at all it'd be much appreciated.
     
    Last edited: Aug 28, 2017
  2. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    I have a better question:
    Why should a sphere not roll down a slope?

    ...

    Before you get upset about the potentially snarky response, please do think about this.
    The most common problem people have when approaching a physics engine in general, is not understanding it... and often times not even understanding what they want from it.

    Seriously, you're wanting to tell the engine "Apply gravity to my sphere" .... "but not when that gravity would cause it to roll down a slope". What did you expect gravity would do?

    Let's take it from this direction:
    Why does a box have an easier time not moving down a slope as compared to a sphere?

    ... trick question. I said "moving". This means, it depends!
    If I am referring to "sliding" motion, the answer is because the box has more surface area contacting the slope, allowing more frictional force to keep it in place.
    If I am referring to "rolling" motion, the answer is because the box must lift part of its body against gravity in order to overcome the 90 degree pivot at its edge to allow the rest of it to fall to a lower position on the slope. The sphere has no pivotal point to overcome, and thus will freely roll down the slope.

    The fact that you mention changing friction makes me feel you don't fully understand the problem here. Increasing the friction is only going to make the sphere roll instead of slide! Frictional coefficient is not the same as "stickiness".

    So my question to you is, why should your sphere not slide OR roll?
     
    PhilSA likes this.
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Essentially a single point, so friction is basically irrelevant. Increase drag in OnCollisionEnter ("ground drag"), reset drag in OnCollisionExit ("air drag").

    --Eric
     
    gamefish likes this.
  4. rbOthree

    rbOthree

    Joined:
    Oct 16, 2010
    Posts:
    67
    @Plystire

    I listed a few of the commonly referenced solutions to avoid responses mentioning them. I appreciate the quick physics lesson, but the effect I'm trying to simulate is general frictional forces that occur due to uneven surfaces. (e.g. blades of grass acting as friction to movement on a ball).

    You mentioned stickiness, and that language seems closer to the effect I am trying to achieve. Does that help phrase this question better?

    @Eric5h5

    Thank you for your answer! Unfortunately playing with air drag only seems to slow down movement, I still get an odd "minimum velocity" at which the ball keeps sliding/rolling regardless of drag.

    My settings for this were:

    Dynamic friction: 1
    Static friction: 1

    On collision enter:
    Drag: 100
    Angular Drag: 100
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    You could continuously increase drag in OnCollisionStay.

    --Eric
     
  6. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Now, I'm just referencing actual physics here, but Drag would need to increase to Infinity to hold a sphere on a slope while under the influence of gravity. I have no idea how the engine actually handles Drag...
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Below a defined delta threshold, the engine considers objects to be not moving and puts them to sleep. But then, setting drag to infinity isn't a problem either:

    infinitedrag.png

    --Eric
     
    ridley1224 likes this.
  8. Plystire

    Plystire

    Joined:
    Oct 30, 2016
    Posts:
    142
    Oh, awesome! I haven't yet used infinity outside of accidents. :oops:
    And the increasing over time will give a nice believable slowing effect. :)
     
  9. rbOthree

    rbOthree

    Joined:
    Oct 16, 2010
    Posts:
    67
    Just wanted to check back in and say this does seem to work quite nicely. Thank you again Eric5h5!