Search Unity

Disabled Physics Components vs. Removed Physics Components

Discussion in 'DOTS Physics' started by florianhanke, Nov 7, 2019.

  1. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Hi all,

    I have an unexpected behaviour regarding the Physics Body GO component. I have a Physics Body component on a vehicle that causes it to drop due to its PhysicsMass ECS component.

    When I start the game with a disabled Physics Body GO component, my assumption was that it would not convert to a PhysicsMass ECS component, but it does (see first half of the GIF). Only when I remove the PB GO component is the ECS component not created (second half of the GIF).

    disabled-components.gif

    Is my assumption correct in that it should not create an ECS component for its entity?

    Cheers and thanks in advance

    P.S: I'm aware that this could as well go into the DOTS forum, but I _think_ the physics authoring components are managed by people reading this forum.

    P.P.S: Never mind the weird colors when the game runs, that is an issue with the URP that I have yet to figure out.

    P.P.S: Just noticed this should have gone into the DOTS Physics forum (https://forum.unity.com/forums/dots-physics.422/) – sorry about that.
     
    Last edited: Nov 7, 2019
  2. Rory_Havok

    Rory_Havok

    Joined:
    Jun 25, 2018
    Posts:
    70
    Yes that is weird. That setup should not result in a PhysicsMass component being created.
    FWIW I just tried the same thing here in the sample scenes and it behaves as expected.
     
  3. steveeHavok

    steveeHavok

    Joined:
    Mar 19, 2019
    Posts:
    480
    Agreed, this is weird. Would it be possible to get a repro of your scene running in the Samples project?

    Making stuff up of the top of my head here: Is this a prefab in the inspector, while we are looking at an instance with the enable flag overriden? Is there a parent GO with another Physics Body component? Do you have your own conversation system in operation? Is the prefab a dependency on a script somewhere else that converts it first?

    Is the graphics material using a ShaderGraph? If so, you might want to try disabling GPU instancing as a short term fix. We had that issue on the samples when we moved to 2019.3.x
     
  4. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Thanks to both of you for confirming that a PhysicsMass ECS component should not be created.

    I forgot letting you know the Unity version. It's 2020.1.0a11 on OS X.

    To answer @steveeHavok 's questions (starting from the 2nd):
    1. It's an instance of a prefab. The Physics Body component is disabled while in the prefab (not visible) it's enabled.
    2. No, this is the top level GO with the Physics GO component.
    3. I have some conversion systems, but not for Physics GO components – I use the Convert To Entity GO component.
    4. Not sure what that exactly means – I use conversion scripts to convert some of my own authoring components.

    To test this I now tried with a fresh project – and started with a non-prefab cube and a prefab cube. Both have this issue (GIF with the same procedure as in the last GIF):

    disabled-components-2.gif

    Here's the manifest:

    Code (JavaScript):
    1. UnityPhysicsBodyTest $ cat Packages/manifest.json
    2. {
    3.   "dependencies": {
    4.     "com.unity.2d.sprite": "1.0.0",
    5.     "com.unity.2d.tilemap": "1.0.0",
    6.     "com.unity.ads": "2.0.8",
    7.     "com.unity.analytics": "3.3.2",
    8.     "com.unity.collab-proxy": "1.2.16",
    9.     "com.unity.ext.nunit": "1.0.0",
    10.     "com.unity.ide.vscode": "1.1.3",
    11.     "com.unity.physics": "0.2.4-preview",
    12.     "com.unity.purchasing": "2.0.6",
    13.     "com.unity.render-pipelines.universal": "7.0.1",
    14.     "com.unity.rendering.hybrid": "0.1.1-preview",
    15.     "com.unity.test-framework": "1.1.5",
    16.     "com.unity.textmeshpro": "2.0.1",
    17.     "com.unity.timeline": "1.3.0-preview.3",
    18.     "com.unity.ugui": "1.0.0",
    19.     "com.unity.xr.management": "3.0.3",
    20.     "com.unity.modules.ai": "1.0.0",
    21.     "com.unity.modules.androidjni": "1.0.0",
    22.     "com.unity.modules.animation": "1.0.0",
    23.     "com.unity.modules.assetbundle": "1.0.0",
    24.     "com.unity.modules.audio": "1.0.0",
    25.     "com.unity.modules.cloth": "1.0.0",
    26.     "com.unity.modules.director": "1.0.0",
    27.     "com.unity.modules.imageconversion": "1.0.0",
    28.     "com.unity.modules.imgui": "1.0.0",
    29.     "com.unity.modules.jsonserialize": "1.0.0",
    30.     "com.unity.modules.particlesystem": "1.0.0",
    31.     "com.unity.modules.physics": "1.0.0",
    32.     "com.unity.modules.physics2d": "1.0.0",
    33.     "com.unity.modules.screencapture": "1.0.0",
    34.     "com.unity.modules.terrain": "1.0.0",
    35.     "com.unity.modules.terrainphysics": "1.0.0",
    36.     "com.unity.modules.tilemap": "1.0.0",
    37.     "com.unity.modules.ui": "1.0.0",
    38.     "com.unity.modules.uielements": "1.0.0",
    39.     "com.unity.modules.umbra": "1.0.0",
    40.     "com.unity.modules.unityanalytics": "1.0.0",
    41.     "com.unity.modules.unitywebrequest": "1.0.0",
    42.     "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    43.     "com.unity.modules.unitywebrequestaudio": "1.0.0",
    44.     "com.unity.modules.unitywebrequesttexture": "1.0.0",
    45.     "com.unity.modules.unitywebrequestwww": "1.0.0",
    46.     "com.unity.modules.vehicles": "1.0.0",
    47.     "com.unity.modules.video": "1.0.0",
    48.     "com.unity.modules.vr": "1.0.0",
    49.     "com.unity.modules.wind": "1.0.0",
    50.     "com.unity.modules.xr": "1.0.0"
    51.   }
    52. }
    I am slightly confused as to which sample scene/Samples project you are talking about. Should I submit the new project depicted in the GIF as a case?

    Re the shader graph question:
    I was using a standard URP lit material with textures on it, no special shader graph (by me).
    In the GIF above, I am using the default URP Lit shader with no textures, and disabled GPU instancing.

    Please let me know if there's anything I can provide to help.
     
    Last edited: Nov 7, 2019
  5. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    I've submitted a minimal reproduction as case 1197207.
     
    steveeHavok likes this.
  6. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Sadly, the answer I got has nothing to do with the minimal case I submitted (afaics) – not sure if this case now is followed up or in limbo…?
     
  7. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Quick update re the above part - I reproduced it, and it appears that the culprit is the SRP Batcher:
    https://forum.unity.com/threads/disco-srp-batcher-bug.778589/

    Thanks for all the support! :)
     
    steveeHavok likes this.
  8. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    In 2020.1.a14 with Entities 0.2.0, the disabled Physics Body GO component does not result in a PhysicsMass component anymore. Thanks!
     
    steveeHavok and Rory_Havok like this.
unityunity