Search Unity

Colliders Intermittently Failing

Discussion in 'Physics for ECS' started by Karearea, Apr 11, 2021.

  1. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    I recently updated my project to Unity 2021.1, with Entitites 0.17 and Havok 0.6, and have been seeing a number of issues with colliders failing, where previously all entities collided as expected.

    The first involves a very simple dynamic character controller with a capsule collider, which must be deactivated whenever the player enters a vehicle. To do this I add a Disabled component using a CommandBuffer, and remove an ActivePlayer component. When the player exits, I update the Translation to an exit position, remove the Disabled component and add the ActivePlayer again.

    As soon as the character reactivates, the collider has no effect. It shows up in the debug display, but simply doesn't collide. This is 100% repeatable. Commenting out the Disabled component CommandBuffer Add fixes this, so presumably the collisions on the entity stay 'Disabled'?

    The second issue is to do with aircraft flying through meshcolliders. The aircraft are dynamic, with compound box colliders. I can't repeat this 100%, but it does seem to be related to other entities with colliders being disabled and reactivated. Speed also has a loose bearing, anywhere more than ~50m/s has a higher chance of breaking through a collider, but it happens at much lower speeds too. In the same circumstances it appears triggers from box colliders are breaking too, but I can't verify this clearly. Again, the debug display looks correct.

    I'm running Havok physics, synchronizing the collision world doesn't help, nor does adjusting the iteration count or FixedStepSimulationSystemGroup timestep. Not really doing anything unusual anywhere, mainly just reading velocities and adding forces using ApplyImpulse().
     
  2. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Went back to first principles and removed elements from a test scene methodically. It appears a very large trigger (c. 10,000 units per side) may have been the culprit for the second issue. Would this make sense?
     
  3. milos85miki

    milos85miki

    Joined:
    Nov 29, 2019
    Posts:
    197
    I see 2 potential causes:
    1. Extremely big body - 10 km is too much, even for Havok. Please try making it 100m, for example.
    2. A job/system changing the collider is running after BuildPhysicsWorld started and before StepPhysicsWorld has completed. Please use the profiler to see what's going on.

    Any changes to entities will only be picked up in BuildPhysicsWorld, so if it didn't pick up the change it won't have effect until the next frame.

    Please let me know if you managed to dig this out.
     
  4. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Hi, thanks for the response. The trigger was a vestigial 'make-it-work' hack that has been replaced by a simple position check. I haven't seen any repeat of the aformentioned issue after continued testing, so I'm tentatively ascribing the bug to that.

    As for the Disabled component issue, I'll keep digging..
     
  5. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    @milos85miki I just saw the pinned message about 2021.1 being unsupported with DOTS. All the above bugs manifested after updating the editor to 2021.1, and I have had a few recurrences even when I thought I’d fixed the project.

    At this point I’ve downgraded to 2020.3 and the issues have disappeared again, so I'm going to chalk this one down to Unity's official warning against DOTS in 2021.1.
     
    milos85miki likes this.
  6. Karearea

    Karearea

    Joined:
    Sep 3, 2012
    Posts:
    386
    Turns out I jumped the gun again. It's easier to regression test and say an intermittent bug does exist than it is to say it doesn't. After more time with the project in 2020.3, the above issues did occur again. However, I saw this thread, and tried turning contact welding off.

    After testing without contact welding, the character controller disabling bug (which had 100% repeatability) completely resolved.

    Furthermore I have spent a lot more time just trying to recreate the conditions for breaking through mesh colliders, and it hasn't happened again. It's clearly difficult to say for certain, but it looks like contact welding is the most likely culprit at this point.
     
  7. RedClawStudios

    RedClawStudios

    Joined:
    Apr 23, 2015
    Posts:
    6
    Hi, upgraded to 2022.2 ... game has been stable since 2018 now colliders all stopped working, all surfaces and characters. No collisions get detected or trigger.
    Super frustrating.
    Resetting does not seem to work, where is the read / write setting please? Can't find.
    Not good QA.
     
  8. JMPM-UNITY

    JMPM-UNITY

    Unity Technologies

    Joined:
    Jun 16, 2021
    Posts:
    94
    Hey @RedClawStudios,
    "Where is the read / write setting please?"
    Are you referring to mesh read/write? If so, I have attached a picture showing where to enable it.
     

    Attached Files: