Search Unity

Large Floor causes instability on objects above it

Discussion in 'Physics for ECS' started by argibaltzi, Apr 8, 2021.

  1. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    Hello
    I started using some cylinder colliders in my world and i noticed they started jumping around (bouncy ) for no reason at all...

    I was able to track down the problem to the floor i am using. I have a very large static floor
    Scale: (1000, 1, 1000) with a simple box collider on it.
    When i change it to (10, 1, 10) then everything works fine.

    I haven't noticed any problems with this collider before so i am not sure what to make of this.

    Is this bad practice? a bug?
     
  2. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    It sounds like you might be hitting floating point accuracy issues when dealing with two bodies that are more than 2 orders of magnitude different in size. Rather than 1 single massive box you should really be starting to think about a terrain (either as a heightfield or mesh). If this is the case then it is similar to simulating bodies far from the origin. Not sure if switching to the Plane shape type would help the floor rather than using a box.

    All that said, I just tried tweaking the Hello World sample to make the letters cylinders and the floor scaled to 1000,1,1000 and I don't see any jitter even with bodies at the far corners. If you have a sample scene to play with it would help find the exact problem.
     
    Last edited: Apr 8, 2021
  3. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    the bodies were all close to zero, its just that the floor collider was massive.
    Funny thing is i been using boxes for most collisions for long time and never saw a problem. Only the cylinder collider is behaving strange
     
  4. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Make sure the cylinder Bevel Radius isn't 0. Not sure why but I do see jitter when I set it to 0. That needs investigating.
    Also, check the box on the floor, if it has flattened to effectively being a plane you'll get issues. You can try refitting the shape to the render mesh.
    Finally, restitution could be having more of an effect on the ends of the cylinder so worth checking that.
     
    argibaltzi likes this.
  5. argibaltzi

    argibaltzi

    Joined:
    Nov 13, 2014
    Posts:
    220
    the plane has a box collider with 1 height, that one is fine
    i just tried a 0.01 bevel and its now stable, it seems the bug is with a 0 bevel radius and a large box collider floor

    I also had friction 1 and restitution 0
     
    steveeHavok likes this.
  6. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    481
    Thanks for the update. It's a good idea to have a non-zero Bevel Radius anyway.