Search Unity

Bug Physics Material ignored at random? (2019.4.0f1)

Discussion in 'Physics' started by DJ-Coco, Aug 21, 2020.

  1. DJ-Coco

    DJ-Coco

    Joined:
    Apr 27, 2014
    Posts:
    47
    I have three physics materials in my game and everything worked fine so far.
    But recently I created a new material for an icy floor in my game and ever since the physics randomly mess up.

    My player character, the rolling ball, occassionally reaches a top speed of 3 km/h, feeling like it was glued to the floor. I noticed this is the result I'd be getting if he didn't use a physics material, but the player physics material is correctly assigned, and printing the values at runtime also yields the correct numbers.

    When I say this happens completely randomly, I mean this sometimes occurs after a script recompile or a prefab change - even in areas completely unrelated to any of this (and the bug randomly gets fixed the same way too).

    It doesn't just affect the player. I also noticed my new icy surface sometimes just doesn't use the material it's supposed to.

    This has never been an issue until I created the new ice physics material and I have no idea why this is happening. The only other thing I did was add a new tag to the tag manager, but I don't see how this would relate to this bug at all.

    I am using 2019.4.0f1, but the changelogs since haven't listed anything related to this bug.
    I want to know whether this is known and what I can do. This would be catastrophic if I compiled the game and some of the physics materials were messed up in the build.


    EDIT: Apparently when the bug occurs, changing a property on the material in question and then changing it back fixes the material. This workaround only appears to work at runtime.
     
    Last edited: Aug 22, 2020
    VenetianFox likes this.
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    If you can create a consistent repro case, you should then file a bug report with it so it can be fixed.
     
  3. DJ-Coco

    DJ-Coco

    Joined:
    Apr 27, 2014
    Posts:
    47
    That might be difficult, giving nobody else ever ran into this issue and I never had issues myself until now.
    Even now, I can't detect a pattern.

    But I'll try whether I can make this issue appear on a small project.
     
  4. nimSony

    nimSony

    Joined:
    Jan 16, 2013
    Posts:
    2
    100% Have this in multiple projects! - Unity 2020.3.8f1

    It happens only between a Rigidbody and Static collider in one of my projects, and suddenly started happening just now on a project I'm working on, but this time between multiple Rigidbodys as well, basically all collisions.

    I added an Audio Source to a few objects and updated their scripts to access AudioSources and boom my project is now ignoring the player's physic material.

    How do I know?
    The Physic Material has 0 friction, 0 dynamic friction, 0 bounce and both combine settings set to minimum, yet even a box with this material, sitting on a slope with this material doesn't slide at all, even when pushed!
    This started happening suddenly, without reloading the engine or anything.

    --------------
    Just restarted the game engine and it's working perfectly like it should again!
    Frustrating.
     
  5. SunnySeb

    SunnySeb

    Joined:
    Mar 31, 2021
    Posts:
    5
  6. Tortuap

    Tortuap

    Joined:
    Dec 4, 2013
    Posts:
    137
    Yeah same here. I have a rigidbody with a physic material, and randomly the physic material seems to get screwed. I'm not sure about the runtime, the bug only happened to me under the editor (2019.4.26f1).

    The values on the material are the ones I set, which are static & dyn friction at zero, but there is definitively some friction.

    Changing the material on rigidbody to an identical one "fixes" the issue, and changing back to the faulty material makes it having friction again.
    Changing the values on the faulty material to whatever and then again to zero fixes the issue with the material.
     
  7. psTom

    psTom

    Joined:
    Jan 23, 2017
    Posts:
    4
    I'm having the same issue on 2020.3.17f1 in editor. Sometimes the reassigned physics material is not acting as it should, there is friction even though material has everything set to 0 and Minimum. The strange thing is that it works when the editor is restarted! I haven't been able to figure out what causes it. But my guess is that it's something getting cached in the physics engine or in integration layer. No idea if it happens in build.

    I do have a workaround that I managed to test in the botched version. I just create a new PhysicsMaterial through code and assign values I want to it and then assign it to the object.
     
  8. yeonghokim

    yeonghokim

    Joined:
    Apr 20, 2020
    Posts:
    9
    Same here on 2020.3.21. Seems to happen at random. Everytime I run into this, I have to restart the editor.
     
    VenetianFox likes this.
  9. yeonghokim

    yeonghokim

    Joined:
    Apr 20, 2020
    Posts:
    9
    I managed to reproduce this issue on my project:
    1. Load a scene using the physicsl material and test -> works.
    2. Without exiting the current playmode, load another scene and then reload the scene in (1) -> now it does't work
    3. Do the same thing as (2) -> works again.
    ...

    This only happens in the editor playmode. I tried the same thing andthis doesn't happen.
     
  10. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    2,508
    Please file a bug report with a repro case, so the Unity devs could fix it.
     
  11. yeonghokim

    yeonghokim

    Joined:
    Apr 20, 2020
    Posts:
    9
    I tried to set up a repro case, but failed. I can't even reproduce the issue in my working project.

    I guess the steps I posted above had been only valid when some internal state has went wrong, for some reason.

    I'll keep updated when I find the actual cause.
     
  12. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    105
    Hey,

    It is an old bug , still here in 2020. I opened a ticket last year, but was closed as I could not find reproduction steps ...
    https://fogbugz.unity3d.com/default.asp?1217291_d6dm3m781djbv52b

    Just to help a bit : in my case , when the bug arise, I can "fix it" by just modifying the material (and set it back to its previous value). It seems to trigger a reload on the material ...
     
  13. FinchWorks

    FinchWorks

    Joined:
    Mar 11, 2014
    Posts:
    2
    Don't really have any additional insight, but just wanted to add my voice. Randomly running into this in 2021.1.4 after messing around with creating joints and changing rigidbody properties through code, though I don't know that it's really related.

    I've got a physics material that normally has 0 friction to prevent a player character from getting stuck on walls. Normally this works fine, but occasionally when hitting play it doesn't seem to read correctly, and the player starts sticking. Also found that restarting the editor fixes it, but it will persist through multiple playmodes.
     
  14. SunnySeb

    SunnySeb

    Joined:
    Mar 31, 2021
    Posts:
    5
    After some month I update my voice too. My project is stable now, but I've given up to fix the 0 friction problem. But I've found the root cause in my project, it is because of the "enable adaptive force" physics parameter, if enabled it creates phantom friction. I cannot disable it in my game, so as a workaround, I created a script to prevent some object to hit each others, it simulates well a 0 friction because if objects are far enough "Enable adaptive force" doesn't add unwanted force on objects.
     
  15. Erikoinen

    Erikoinen

    Joined:
    Nov 10, 2014
    Posts:
    68
    Yup, still experiencing in Unity 2021.2.19f1. Often it seems that the issue can be fixed (for a time) by fiddling with the params of the material in question, but even that doesn't always seem to resolve the issue. And even if it does, it happens after some minutes-hours-days. No idea what could cause it.
     
  16. brandonjames444

    brandonjames444

    Joined:
    Aug 28, 2019
    Posts:
    2
    I believe I have found a fix for this. Under physics in the project settings I placed a default material (for my project I used 0 / 0 / 0 / min / min) and the issue has stopped. I could be wrong and it may just be that the bug stopped occurring temporarily, its really hard to tell. I hope this is a permanent solution.
     
  17. el_Guero

    el_Guero

    Joined:
    Sep 15, 2017
    Posts:
    185
    Same problem in latest 2021.3.14. I never had that experienced before. Now it happens every other run after some time of playing.

    And as pointed out by others, I can just change a random setting in the material and it resets and works well again.

    I hope that doesn't happen in the exported version... would be a retention killer.
     
  18. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    105
    Not working for me. It works only for object that use this exact material. But if I use a different material the bug can still happens