Search Unity

Rigidbody sphere never stops rolling

Discussion in 'Scripting' started by unikum, Nov 3, 2010.

  1. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    I have set up a simple scene with a flat cube (ground) and a sphere (ball) to play around and try to simulate a football (soccer) ball physics. However, the ball never stops rolling on the ground. It keeps rolling extremely slow forever, how come?

    I've tried changing friction values without success. What do I need to do for the ball to behave like it is rolling on grass (stopping full and goes in to sleep)? I've changed friction values on the physics materials on both object but I can never get it to fully stop.

    What did I miss?
     
  2. SarperS

    SarperS

    Joined:
    Mar 10, 2009
    Posts:
    824
  3. unikum

    unikum

    Joined:
    Oct 14, 2009
    Posts:
    58
    Trying it without success. Shouldn't the ball keep going slower and slower because of the friction? it doesn't slow down, it's keeping a constant low speed after initial slowing down. That constant angular velocity ranges between like 1.5 and down. If I put in another cube as a wall it stops and goes to sleep.

    Don't understand why the friction doesn't keeps making it roll slower, down to basically standing still.

    Edit: I had the "drag" on 0... seems to work properly now.
     
    Last edited: Nov 3, 2010
    spotlessapple likes this.
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Friction won't slow it down because a sphere only has a tiny point actually touching a cube, so there's nothing really for friction to act on. It's not like a real soccer ball where you actually have lots of grass blades and stuff in contact with the ball at various points. Friction works for things like boxes because the entire surface is likely to be in contact with the ground.

    --Eric
     
    eterlan likes this.
  5. JRavey

    JRavey

    Joined:
    May 12, 2009
    Posts:
    2,377
    salimkham and mdrunk like this.
  6. crazyKnight

    crazyKnight

    Joined:
    Nov 22, 2010
    Posts:
    55
    hi,

    thanks a lot the drag worked perfectly

    ....
     
  7. SpaceManDan

    SpaceManDan

    Joined:
    Aug 3, 2013
    Posts:
    15
    could do something like:

    float velocitySqrMagThreshold = 0.6f;
    float rBVelocitySqrMag = rigidbody.velocity.sqrMagnitude;

    if (rBVelocitySqrMag < velocitySqrMagThreshold)
    {
    canActivateDragDamping = true;
    }
    else
    {
    canActivateDragDamping = false;
    }

    if (canActivateDragDamping)
    {
    rigibody.drag = 10;
    rigidbody.angularDrag = 10;
    }
    else if (!canActivateDragDamping)
    {
    rigidbody.drag = 0;
    rigidbody.angularDrag = 0.05f;
    }



    Note: velocitySqrMagThreshold --- I suggest setting this to 0.6 for the sphere issue. Also I suggest setting up lerps instead of what I have here for when drag is kicked into play. It smooths it out so it doesn't pop. But this should get you started and you can do the lerp code yourself. I donnwanna.

    Hope this helps.
     
  8. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    maybe your "ground" is just a bit rotated? on the X or Z axis?
     
  9. SarperS

    SarperS

    Joined:
    Mar 10, 2009
    Posts:
    824
  10. Karsten

    Karsten

    Joined:
    Apr 8, 2012
    Posts:
    187
    oh yeah, necro much. there was something wrong with the database of this forum i seen, there was some threads with extreme high views , maybe they try around again with the new forum software xD
     
  11. unity_steph

    unity_steph

    Joined:
    Apr 9, 2018
    Posts:
    1
    I tried to find a solution for many hours, so if it can help : try changing the ground's collider. It worked for me because I was using a mesh collider instead of a box collider.
     
  12. valentin56610

    valentin56610

    Joined:
    Jan 22, 2019
    Posts:
    156
    Thought I'd chime in and say that adjusting the drag worked for me (flat ground, capsule collider on a shell casing object, set drag on 10)
    Without drag on 10 it would roll and roll and roll...