Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Separating objects is inconsistent and takes up to 20 seconds Physics2D.FindNewContacts calls.

Discussion in '2D' started by StuwuStudio, May 1, 2022.

  1. StuwuStudio

    StuwuStudio

    Joined:
    Feb 4, 2015
    Posts:
    165
    Hi,
    I'm working on a worms-like with dynamic terrain. I was wondering how should fix my issue with making sure the terrain splits correctly when broken up mid-air. What I'm using right now is adding the fixed joint for a single frame between the original piece and the chunk that has been taken off of it.

    It usually looks ok but it's wildly inconsistent.
    He's an example when it works relatively well (minus the part where sometimes the chunk taken off stops rotating, and where both pieces would start jittering for a frame after being separated.


    Sometimes, for some unknown reason, the game will freeze for up to 6 sec after the split with this profile log:




    Some other times, the pieces will be flicked at high speed for no reason,
    other times they stop mid-air.
     
  2. StuwuStudio

    StuwuStudio

    Joined:
    Feb 4, 2015
    Posts:
    165
    I just got a 157sec spike:
    CPU:

    Physics before:

    Physics after:

    Notice the 100k contacts...
     
  3. StuwuStudio

    StuwuStudio

    Joined:
    Feb 4, 2015
    Posts:
    165
    I just notice my links broke, and my question still hasn't been answered.
    I'm still getting the game issue, I can't find why.


    The lag spike lasts for a while and the step time is almost always over a second.
    There doesn't seem to be any overlapping geometry, the contact count seems relatively low. What could be causing this?