Search Unity

Bug IN-34662 physx joint baking broken

Discussion in 'Physics for ECS' started by thelebaron, May 27, 2022.

  1. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    I only just noticed this but I'm getting wildly different results from joint conversion seemingly post 0.6.x with 0.50.p43.

    The culprit seems to be my character/configurable joints dont appear to have any limits after converted, Ive added some gifs to illustrate this. Prior to 0.50, I was getting what I'd assume were correct results from conversion, but now it appears wildly different.

    same character

    physx - character keels over due to limits as expected


    after conversion unity/havok physics - character kind of just deflates like a sad balloon.


    and just another extended result

     
    Last edited: May 27, 2022
    Lukas_Kastern likes this.
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    replacement code
    https://gist.github.com/thelebaron/f51c88d65f9239ae1a961fc37408051c

    Sort of fixed it


    Had saved some old joint conversion code way back when joints were introduced in the package, which I copied and used for manual entity joint setup.
    Replaced the code inside the current "CreateConfigurableJoint" in LegacyJointConversionSystem.cs, and it appears to more or less convert properly.
     
    Last edited: May 27, 2022
    daniel-holz and Lukas_Kastern like this.
  3. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    Still seems to be the case with latest physics - physics 1.0.0pre44


    red is dots, and green is physx: they have the exact same physx settings.
     
  4. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857


    reported as IN-34662. going by the thread date, am i seriously the only person using this? its been broken for almost a year?
     
  5. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    Are you creating the ragdolls with the legacy physix joints?

    I noticed that not all things are properly mapped from the legacy joint editor component to the unity physics equivalent.

    But creating ragdolls from script seems to work.

    Their Ragdoll sample scene here:
    https://github.com/Unity-Technologi.../master/PhysicsSamples/Assets/Demos/4. Joints

    Was broken for a while when they moved to the new transform system, but seems to be working now again.

    They don't use the editor at all and just create those joints from code.

    Have you tried with both their new physics joints authoring components from the sample project and the legacy ones?

    Do you observe the same if you use the authoring components from the samples?
     
    daniel-holz likes this.
  6. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    857
    I'm not using the samples(think we went over this in discord) joint authoring as they aren't official. If later down the line some ui update breaks the inspector or whatever for those authoring component samples and unity decides never to bother to update it, its one less thing I would rather not have to fix on my own.
    Trust me I've done the whole shebang of ragdolls from code, but Unity added real actual joint conversion way back before 0.17, but it broke somewhere after that and now its been broken for some time. The dots blitz day mentioned that the idea was to use the physx components as the proper way to author / and some rearchitecture was in the works (https://forum.unity.com/threads/physics-authoring-components.1371141/).
    If there weren't any joint conversion code aside from the samples this might have more merit, but unity provides builtin stuff that has been broken for quite a while.

    Even in the post here suggests to use builtin physx stuff as an alternative - https://forum.unity.com/threads/doe...ive-script-for-making-active-ragdoll.1413216/ this person will eventually experience the same result.

    If unity doesn't actually plan to support this workflow of physx joints to dots, it should just be removed outright.

    The code I posted here still works as a fix(obviously you will have to rework it a bit to conform with the new bakers) and passes the eye test but as for being an actual correct result I'm not sure as I'm pretty far from being knowledgeable on how joints work.
     
    daniel-holz and Volshar like this.
  7. daniel-holz

    daniel-holz

    Unity Technologies

    Joined:
    Sep 17, 2021
    Posts:
    278
    @thelebaron : We recently confirmed (see other thread here) that there is a discrepancy in the Character Joint and Configurable Joint behavior when baking them to Unity Physics compared to the built-in physics simulation.

    The issue occurs notably with the default stiffness and damping parameters (both zero), in which case Unity Physics physically correctly models the limit with "zero resistance force", whereas the built-in physics simulates in this case a "default stiff" limit behavior.

    I saw that in your replacement code you are simply using "always stiff" parameters within the baker, which would explain why the replacement code fixes the issue for the default parameterization.
    We are tracking this problem internally and are working on a solution.