Search Unity

[RESOLVED] 2018.3 Physics are jumpy on non-convex mesh colliders.

Discussion in 'Physics' started by DreamEnder, Jan 8, 2019.

  1. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    After upgrading our trials game to 2018.3 the bikes do not drive like they used to. When the wheel (sphere collider) hits certain non-convex mesh colliders the bike bounces backwards violently. In the past it would just ride over it or jump up a bit. You notice it when driving up stairs as the bike sometimes bounces backwards or launches in the air.
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    While there are changes (check out physics settings and release notes), nobody can really help you with this lack of information. You'll have to be a lot more detailed.

    Check out the 2018.3 release notes in detail. This isn't an optional step for physics based games.
     
  3. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    Here's a video of the bike behaving erratic.



    And here are some screenshots of the settings:

    Screen Shot 2019-01-09 at 8.25.58 PM.png

    Front spoke setup:

    Screen Shot 2019-01-09 at 8.25.48 PM.png

    Front wheel setup:

    Screen Shot 2019-01-09 at 8.25.36 PM.png

    It looks like the wheel is going into the mesh collider and then suddenly bouncing back.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    What version did you update from?
    What is the code for when your wheel come in contact with the surface? Do you do anything special?

    Can you enable Physics debug? Window->analysis->
    Check the world colliders are correct.
     
  5. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    Thanks for your responses. I tried the physics debug and played the game in slow motion. It appears that the wheel (sphere collider) intersects with the obstacles mesh collider for a millisecond as the bike is driving. The physics then pushes back suddenly causing the bike to shoot backwards.

    How can I increase the physics speed? I've tried changing solver iterations but nothing changes. Also my fixed time step is at 0.01 which I'm reluctant to increase as this is a mobile game.
     
  6. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    Here's some screenshots of it happening:

    Screen Shot 2019-01-10 at 8.31.45 PM.png Screen Shot 2019-01-10 at 8.32.00 PM.png Screen Shot 2019-01-10 at 8.32.13 PM.png

    This only happens with mesh colliders that are non-convex.
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You might have luck simply adjusting where the collider is. One thing that changed recently was the default contact offset, which controls how much things can penetrate.

    It seems to me your game is using a broken physics material for the sphere collider. it Should never bounce back unless it had a default bouncy material. It would simply stop no matter how fast you were going, or slide.

    You will want to look at the contact pairs mode too and contacts generation. As you probably set up your game to work in such a way that's not robust (or it'd have easily survived the migration) but as something kinda hacky. I don't mean this offensively - most games are kinda hacky.

    Some hacks aren't very robust though.
     
  8. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    The wheel has a physics material with 0 bounciness set to minimum. The level mesh colliders have the default physics material.

    I don't think it matters what physics material I use. It seems that the physics is lagging and letting sphere colliders intersect with mesh colliders and then jerking back to correct itself.

    I will tweak contact offset and see if that does anything.
     
  9. DreamEnder

    DreamEnder

    Joined:
    Apr 12, 2011
    Posts:
    191
    So I fixed the issue by changing the setting of cooking options on every mesh collider to None.
     
  10. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    In general it's better to create a primitive box out version for the colliders instead of mesh ones.
    (For this types of stairs)
    This will improve performance as well, as non-convex mesh collision resolution is quite slow.