Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2D physics jitter, what settings solve this?

Discussion in 'Physics' started by Deeeds, Apr 8, 2018.

Thread Status:
Not open for further replies.
  1. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    I've got everything at normal, default settings, except for a gravity of -30 instead of -9.81

    And this is causing a jitter, like so:

    jitteer.gif

    Which settings will fix this most efficiently?
     
  2. PGJ

    PGJ

    Joined:
    Jan 21, 2014
    Posts:
    899
    Have you tried changing the sleep times in the physics settings?
     
  3. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    I don't want the object to sleep. I want it to simply stop jittering. This jittering also happens when it's rolling along the ground.
     
  4. Fu11English

    Fu11English

    Joined:
    Feb 27, 2012
    Posts:
    258
    Potentially it could be fixed with the default contact offset being too small. You may be able to increase it a bit depending on your required accuracy.

    Otherwise you need to lower the fixed timestep or increase solver iteration count. Or a combination of the 2.
     
    Deeeds likes this.
  5. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    What does it look like with less gravity force? Is gravity the only force applied here or are you doing something else to it? Also, what size is this object i.e. is it extremely tiny? Maybe you have a physics material with bounce? Try using continuous collision detection on the Rigidbody2D.

    It's very hard to give exact recommendations without knowing what is going on here.
     
  6. Deeeds

    Deeeds

    Joined:
    Mar 15, 2018
    Posts:
    739
    This is a standard 2D project, as created by Unity. The circle is made in this way, and not changed from its default size:

    Screen Shot 2018-04-13 at 9.53.57 pm.png

    The physics material has a bounciness of .3, the ground has zero bounciness. The ball is dropped, this jittering is the result, each time. If the ball drops at an angle, or has angular forced added, it also rolls with this jitter.

    The only thing changed (in the scene or otherwise) are the adding of bounciness to the ball and increasing gravity to -30.

    Yes, continuous collision does somewhat resolve this. It settles, which is a huge benefit, and how I'd like it to behave.... better than bouncing forever. Is continuous collision the optimal way to handle this sort of issue?

    With less gravity, it settled, after a bit of jiggling. It never settles at a gravity of -30.
     
  7. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Yes, you can use continuous collision detection here (more expensive in CPU cost than discrete) and/or you can increase the velocity threshold which cost nothing extra and controls when a collision should be considered inelastic.

    A really great talk about this can be found here. At 4:10 there's a discussion on jitter and avoiding it.
     
    Last edited: Apr 13, 2018
  8. lastkatana

    lastkatana

    Joined:
    May 3, 2019
    Posts:
    8
    I'm facing the same issue, what did you end up using?
     
  9. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,321
    Probably increasing the gravity to -30 wasn't helping. As you make things extremely, you often either need to reduce forces or increase the solver iterations so it has more change to converge on a solution.

    Did you look at the video, that describes that issue? Note that Deeds isn't around here anymore.
     
    Last edited: Apr 29, 2020
  10. puntawat1412

    puntawat1412

    Joined:
    May 29, 2020
    Posts:
    2
    For me, I solved this by increase the bounce threshold (The "Physics" menu). The idea is the ball will keep bouncing when the relative velocity (Bounce Threshold value) larger than this threshold. So setting this to a bit bigger will stop the ball jitter near. Also you can try the interpolate on rigidbody to smooth it.
     
  11. lookerscommunity

    lookerscommunity

    Joined:
    Jan 26, 2020
    Posts:
    1
    If it is about 2D project, there is a "Simulation Mode" option in the "Physics" menu (located in Project Settings). If set to "Update" instead of "Fixed Update" the bouncing should disappear, because there will be no delay in collisions.
     
Thread Status:
Not open for further replies.