Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question rigidbody2d and circelcollider2d stacking shake

Discussion in 'Physics' started by qq534575060, Jan 25, 2024.

  1. qq534575060

    qq534575060

    Joined:
    Jul 19, 2017
    Posts:
    7
    I am making a game in which fruits fall due to physical gravity. Fruits of the same type will be synthesized into new fruits after collision. However, during the production process, I found that when the fruits are stacked very high in the scene, the fruits will shake and rotate. , what's going on?
    I used the UGUI Image to bind the rigidbody2d and circelcollider2d components, and used Continuous and Interpolate, but I still have this problem.
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,657
    In the end, the solver is doing its best to keep things stable however doing things such as having stacks of masses beyond the 10:1 ratio and not increasing the solver iterations beyond the defaults when things get complex can make this hard to solve for it. Also, critically, you should not be doing any work on the Transforms at all if you want to allow physics to solve things without interruption. Finally, adding in restitution (bounce) can make forces amplify throughout the stacks so presumably here you've got that set to zero. Also super high friction can do the same.

    That said, 2D physics (Box2D) is very stable. Here's an older video where a bunch of Rigidbody2D/CircleCollider2D using continuous are just dropped on each other. They all have the same mass but I recall increasing the solver iterations as it's not a simple solver situation:
     
    qq534575060 likes this.
  3. qq534575060

    qq534575060

    Joined:
    Jul 19, 2017
    Posts:
    7
    thank you for your reply
    Yes, the Friction setting in my PhysicsMaterial is 0.1, and the Bounciness setting is 0 (because I don’t want to bounce). Now I have changed it to 1 and 0.1. This problem does not seem to occur again. Thanks again.
     
  4. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    11,657
    A little confused by your reply. You're saying you set the Friction=1 and Bounce=0.1 and it has gone away? I'm not sure I understand why. Increasing the bounce should not solve that although I could understand how increasing friction slightly might for a specific case.

    I am assuming of course that the 2D physics settings are at default and you're also running the simulation during the FixedUpdate.

    I guess either way, as long as you're happy with it even if I don't follow how that would solve it. :)
     
    qq534575060 likes this.