Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Physics2D increases activity when... not moving?

Discussion in 'Scripting' started by UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9, Aug 17, 2020.

  1. UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    Joined:
    Dec 3, 2017
    Posts:
    21
    lol.gif
    As you can see in the profiler, the Physics2D increases over time when all the physics objects are still. But as soon as my Main character moves, the CPU usage becomes 0.

    This problem makes me go from 160 fps to less than 20 in about 30 seconds. The profiler says that here's the problem:

    profilerlog.png

    Physics2D.FindNewContactsFindJob

    But I cannot imagine what's going on and why it grows over time. I need a clue to where to look. Can anyone help me? I am really desperate on this one.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,947
    I think there's a special physics section of the profiler that should say how many physics objects of certain types are in the scene. Have you looked at that? Maybe you have some invisible or off camera objects you forgot about?
     
  3. UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    Joined:
    Dec 3, 2017
    Posts:
    21
    Where is this section? The physics debug window shows nothing.

    The point is that there's no new items being created. There's nothing happening, but it still grows.
    This is the memory:
    Used Total: 0.79 GB Unity: 180.7 MB Mono: 13.4 MB GfxDriver: 126.1 MB Audio: 9.0 MB Video: 0 B Profiler: 476.5 MB
    Reserved Total: 2.31 GB Unity: 0.62 GB Mono: 17.2 MB GfxDriver: 126.1 MB Audio: 9.0 MB Video: 0 B Profiler: 1.54 GB
    Total System Memory Usage: 3.06 GB

    Textures: 885 / 54.9 MB
    Meshes: 88 / 18.1 MB
    Materials: 107 / 194.0 KB
    AnimationClips: 54 / 357.0 KB
    AudioClips: 30 / 7.0 MB
    Assets: 5095
    GameObjects in Scene: 781
    Total Objects in Scene: 5345
    Total Object Count: 10440
    GC Allocations per Frame: 106 / 30.0 KB

    All the rigid bodies are kinematic, so I would assume there's no problem. But there is. I still don't know where to start the search.
     
  4. UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    Joined:
    Dec 3, 2017
    Posts:
    21
    Sorry for the bump. I was not able to solve this. I just need a hint of what could be going wrong.
     
  5. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,947
    Are you sure this number is not growing over time?

    GameObjects in Scene: 781
    Total Objects in Scene: 5345
    Total Object Count: 10440
     
  6. UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    UDN_46c91c6c-aeb1-471f-87fb-917fc1db02c9

    Joined:
    Dec 3, 2017
    Posts:
    21
    Certainly. There's nothing happening in the scene.

    I am starting to think it's a problem with Physics. I removed all the scripts leaving only rigidbodies and their respective colliders. The problem seems to trigger when I change the transform of the object. For instance, by moving the object manually through the scene, it triggers the problem. When it detects a collision, it seems to reset the problem. But when there's no new collisions it keeps growing.





    Maybe I should ask in the physics subforum.
     
    PraetorBlue likes this.