Search Unity

Rigidbody Sphere skids around, how to stop?

Discussion in 'Editor & General Support' started by DonGato, Jul 5, 2011.

  1. DonGato

    DonGato

    Joined:
    Dec 9, 2010
    Posts:
    45
    Okay I am trying to control a ball using Rigidbody.AddTorque, but I am having issues with the ball sliding around. When I change direction, or start moving from a stop the ball first skids in place before beginning to move in the correct direction. There is a Physics Material on the terrain with all friction values maxed to 1, and the friction combine set to maximum.

    So, solutions? As I understand it the issue comes from there being such a small amount of contact between the ball and the terrain, but I don't know how to make it work. I want the ball to be fully physics driven, and to not skid at all, when changing direction.
     
  2. DonGato

    DonGato

    Joined:
    Dec 9, 2010
    Posts:
    45
  3. DonGato

    DonGato

    Joined:
    Dec 9, 2010
    Posts:
    45
    Baddabump
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Since its been ages since the bump, I think it was a well-deserved bump.

    I am assuming you mean the ball isn't rolling. You say: " the ball first skids in place before beginning to move in the correct direction". Do you mean roll, because that sentence doesn't make any sense. Skidding is movement, not rotation or rolling. I think you mean rolling though.

    If you mean you want to roll the ball and it must only roll to move, then you need to think about how you're going to do it.

    1. do we adjust physics values like iterations or frequenct of fixed update? do we adjust mass and so on?

    2. you can simply set the current rotation based on the ball's x and z values. This would give you a 1:1 correlation between the rotation the ball currently is, and it's position. This means that the rolling is a visual effect only, but if you are rolling a ball, this is ideal.

    I would need a lot more clarification because I'm just guessing this end what you're trying to achieve. When making forum posts for help, assume you are talking about your project to a flower picking class for old ladies. This way, we get a really clear idea.
     
  5. Warren

    Warren

    Joined:
    May 5, 2011
    Posts:
    17
    I have a similar problem. I want a ball with a sphere collider to roll to a stop quickly, but the friction value in the physics material maxes out at 1 so it takes FOREVER. It would be really nice if this value could be set higher. Using a mesh collider seems like it might help, but that's not ideal.
     
  6. DonGato

    DonGato

    Joined:
    Dec 9, 2010
    Posts:
    45
    Couldn't figure out a really good way to explain it, so I made a video! Isn't technology great when it is doing what you want it too :p



    This is what I have. Notice how when I change directions (or start moving from a stop) the amount of rotation is far greater than the amount I actually move over the ground?

    I want it to be 1:1, so if the ball rotates one full revolution, it moves a distance over ground == to its circumference.

    I thought of handling rotation and movement separately, with movement tied into RPM's of the ball, but Iam unsure how to handle things when "rolling" up or down a hill or slope.
     
    Last edited: Jul 13, 2011
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    That is exactly what I've pointed out in the above post.

    You can't turn it and have it 1:1 with it. It can't be done short of whacking up every concievable physics attribute possible, increasing weight and mass a huge amount and then setting FixedUpdate to an insanely high frequency.

    When all you actually need to do is set the rigidbody to NOT rotate, but slide it around with forces, and then rotate the mesh based on X and Z. Try it and you'll see what I mean, and it will have zero skidding and look perfect.

    Physx in unity isn't a scientific physics simulator - its a physics engine for games built for speed over accuracy, so there will always, always be issues like this that you need to fudge, work around or simply correct with your own maths.

    The simplest solution which works perfectly is described in this post.

    However if you want to try and do this without using the mesh/position hack, you can use AddForce or increase gravity a great deal. This should at least give the ball much more contact time with the floor and hopefully at least render this issue fairly undetected. Good luck.

    As I said, make the rotation = the position. For example x rotation is one axis and y or z rotation the other position axis. I have already done this ball rolling stuff about 5 years ago in Blitz3D doing exactly those things. It's one of those things you need to try to see "oh yeah... of course it works".
     
    Last edited: Jul 13, 2011