Search Unity

Request for Information on Physics changes

Discussion in '2017.2 Beta' started by jrhtcg, Aug 4, 2017.

  1. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    I have a player rig that uses 3 rigid bodies and two configurable joints. My rig had some real issues with beta 4, but beta 5 seems to a little better. I am trying to track down one last glitch, but it is very hard because the glitch does not always show up in editor mode while being prevalent in the build version.

    I think it has something to do with assigning the rotation on the transform. In the past that did not seem to be a problem, now it seems to affect the physics calculations, but to be honest I am not sure at this point.

    I am hoping someone with Unity can make a post with what was changed in regards to the configurable joints. So that I can focus my efforts a bit more on what is causing the glitch.
     
  2. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    Additional Information: I think my issue has something to do with the inertiaTensor value. When I run the game in the editor most times the inertiaTensor value for my rigidbody start at around 1.3 for the x and z values, and .85 for the y value. Every thing runs as expected when I get these values.

    Sometimes, and quite randomly the inertiaTensor values start at something like 34.1 for the x and z values, and more like .92 for the y value.

    I have to admit I do not really understand the usage of inertiaTensor or how it is being calculated, all I know is that it appears to be out of whack when I am experiencing the jittery effect that I am seeing.

    Any suggestions on what to try to fix this would be appreciated.
     
  3. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    After reading up on inertiaTensor I decided to simplify my colliders for my rig. I removed a sphere collider and a cylinder collider attached to a child object. I also modeled a simplified mesh collider. That seemed to fix the issue I was having. It was likely the mesh collider that was causing the problem. This does not explain the random nature of the bug, as in why sometimes it would calculate correctly in the editor and sometimes not, but at least it is resolved for my particular case.

    Edit: so this is starting to get on my nerves a bit. I apparently did not test it long enough, because it just messed up again. I removed the mesh collider, and now only using a single sphere collider. So far so good, but not really a solution to my problem. I have a buoyancy script that needs a mesh collider to work.
     
    Last edited: Aug 5, 2017
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,174
    Are your mesh colliders marked convex? I think you're probably running into iteration issues. When you have a chain, the masses mustn't be much different from each other. Ideally, the further down the chain you go, the less the mass must be to remain stable... you could raise your iterations too.

    There was work being done on a super stable new joint type but I think @yant gave up on it (he is an overworked soul) :)
     
  5. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    I will try messing with the iterations and maybe adjusting the masses. Thanks for the suggestions.
     
  6. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    @hippocoder: I tried your suggestions but no joy.

    I reloaded 2017.1 and I do not have this issue with that version. Something about the beta is broken when calculating the inertiaTensor. I could not figure out the root cause, however. It seemed to break regardless of whether I used a mesh collider or a simple sphere collider. The random nature (at least in the editor) of the bug is very strange. I can tell in the first update call if it was going to work or not, by looking at the inertiaTensor values. When it worked, it worked fine without fail. When the inertiaTensor values were off, nothing I did seem to get them to reset, and I would experiance a jerky motion in my player rig.

    Unless someone has something else to try, I guess I will wait for the next beta and hope it gets fixed.
     
  7. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    28,174
    Is inertia tensor mentioned in the release notes? this probably is a bug of some sort then.
     
  8. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,837
    Hi jrhtcg,
    Could you please file a bug report with a minimal reproduction case and reply in here with the case #?
     
  9. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    @LeonardP: Thanks for the response. I try to get that done sometime today and post the case # as requested. Thanks
     
    LeonhardP likes this.
  10. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    Here is the case# for the bug report: 939928
     
  11. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    528
    I haven't yet had a look into the report, but there might be a ton of changes that affected what you describe. If it's 17.2 beta 4, it must come down from either the deferred physics updates or the rebuilt PhysX that we apparently shipped with a bad fix recently. I'll take a look.

    As for joints, there was a tiny change done for 17.1 -- https://docs.unity3d.com/2017.1/Documentation/ScriptReference/Joint-massScale.html. Practically, it's a way to make the objects look like they have equal masses only for the solver (to help it converge faster), while having the interaction with the surrounding objects as normal.

    The super-stable joint @hippocoder talks about is the ArticulationJoint, it's in the plan, but I'm not able to say when it lands yet. Looks more like mid 2018 at this point in time.
     
    hippocoder likes this.
  12. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    @yant: Thanks for the response.

    After posting the bug report I received an email from unity saying something to the effect that they thought this bug is fixed in an as yet unreleased beta, but they could not say when the next beta would be released. The funny thing is beta 6 was released the day after I received the email, but the bug still exists in beta 6. I will just wait it out for the next release and see if it is fixed.

    I read the link about the massScale feature. Interesting feature. Something hippocoder posted made me already adjust my masses to all be the same, but that had no effect.

    I am also considering calculating my own intertialTensor values, but I will have to do some heavy reading first as that is a little above my pay grade! ;)
     
  13. jrhtcg

    jrhtcg

    Joined:
    Jul 13, 2013
    Posts:
    34
    I am not sure how to word this, but my bad!

    I finally figure out the problem, and it was not exactly a unity bug. I had a "buoyancy" script attached to my player rig, and I had not considered it in all my test as the possible culprit. It was not my code, so I was not looking at it for possible incorrect usage.

    Turns out that it was setting the centerOfMass on the rigidbody it was attached to. This was the source of my inertiaTensors being calculated incorrectly.

    I have been using this script for several unity versions now, and it only showed up as an error in 2017.2. I am guessing that the timing of loading monobehaviors has changed and while this was always bad code, it only showed up in 2017.2.
     
unityunity