Search Unity

Question How has rigidbody (3D) behaviour changed between U2023.1.3 and 2023.2.x?

Discussion in 'Physics' started by sstrong, Feb 5, 2024.

  1. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    I have a system that applies AddRelativeForce and AddRelativeTorque to a rigidbody that has worked fine from U2018.4 until 2023.1.3 (including all major releases in between).

    Somewhere between U2023.1.3 and U2023.2.3 it started giving very different results (with the same code).

    What has changed and how might I give similar if not identical results with U2023.3+?

    If we could understand exactly what Unity changed, maybe we could get to having a working system.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Very unlikely anything changed between those versions. AFAIK they all use the same version of PhysX. What kind of difference are you seeing? I think the most likely answer is that your code is framerate dependent, and there has been a performance improvement or regression.

    This discussion would be a lot easier if you show your code and how the results have changed.
     
  3. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    Given our (complex math) code has worked so well for thousands of customers over so much different hardware and such a large range of Unity versions (2018.4 - 2032.1) over many years of constant improvement, it is very unlikely to be a coding issue on our part.

    The fact that Unity continually just randomly breaks stuff is a constant frustration to asset publishers.

    What they have changed that would affect applying force and torque to a rigidbody, we have no idea.
     
  4. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,928
    "The problem can't possibly be this" is usually followed by the realization that it was, indeed.

    I also develop physics stuff that has worked since 2019.4 using AddRelativeForce/Torque, and I can't find any differences in behavior in 2023.2 vs 2021.4 vs 2019.4, so I'm quite skeptic that anything at all has changed regarding this in 2023.2.

    Ditto, however of all things physics are quite robust since the core engine is not developed by Unity (PhysX by Nvidia) and seldom changes between Unity versions.


    Your best bet is to try and build a minimal example that reproduces the issue you're getting. While doing this there's a chance you'll find the reason why it behaves differently and be able to work around it, and if you don't find the reason, you'll have a nice repro scene for Unity to take a look at so that they can fix it, win-win.
     
    Last edited: Feb 7, 2024
    PraetorBlue likes this.
  5. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    Found it. AddRelativeForce behaviour has changed. In (all??) previous Unity versions it applied relative force to the centre of mass. Now it appears to apply it to centre of the object (0,0,0) in local space.
     
  6. marcoantap

    marcoantap

    Joined:
    Sep 23, 2012
    Posts:
    227
    You could simply create a test suite that validates the expected results and avoid versions until Unity unbreaks it.
     
  7. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    It's an asset for the store. We have a workaround (which mostly works). I'm going to create a simple re-pro project and file a bug report - now we know what the issue is.
     
  8. sstrong

    sstrong

    Joined:
    Oct 16, 2013
    Posts:
    2,252
    In case you get run into this, it's broken between U2023.2 and U2023.2.15 and U6000 beta 12 and below.

    Essentially, although they didn't change the physics engine, they changed the behaviour of adding force to a rigidbody by not applying it to the centre of mass.

    Unity Issue Tracker - Rigidbody.AddRelativeForce() causes unexpected GameObject rotation (unity3d.com)