Search Unity

Unity is creating static colliders on load.

Discussion in 'Editor & General Support' started by ThomHurks, Jan 26, 2011.

  1. ThomHurks

    ThomHurks

    Joined:
    Jul 27, 2010
    Posts:
    22
    Hey,

    I noticed that one of my coroutines which moves a couple of objects around each x amount of time was being slow.
    When investigating it in the profiler, I found it was doing static collider moves.

    Static collider moves only happen when you move an object with a collider, but without a rigidbody.
    Well, *all* my objects with colliders have kinematic rigidbodies. All of them, I check multiple times to be sure.

    So, where are these static collider errors coming from?

    I was investigating more, and I found this in the profiler a short while (1.5 ms) after starting the game:

    Application.Integrate Assets in Background.
    Application.LoadLevelAsync Integrate
    Loading.AwakeFromLoad
    Mesh.Bake Scaled Mesh PhysX CollisionData
    Static Collider.Create (Expensive delayed cost)

    Does anyone know why Unity creates static colliders on load apparently, and how to prevent it?

    Thanks!
     
  2. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    Well it should create it only if used. While it is to late probably to fix for 3.2, fire a bug report and drop me a case number
     
  3. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    On terrains it seems to always create it at least in 3.1 (delay of 1.1s on my core i7 920 @ 3.2ghz), even with the terrain collider removed. if I would have to guess then I would assume that potentially at least there foliage / detail object usage might have to do with it, is that possible? (thats the only thing we use from it, we actually use pure meshes for all the rest and use terrains just for these 2 things thus wanted to get rid of that 1s++ stall)
     
  4. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    You do judge about it from profiler readings or from the fact that it takes time? ;-) Not that i know, but i'd start with that anyway
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    From profiler :)

    From the fact that it takes time, I would be unable to make a difference from 1-4s I guess ;)
    Problem is that it has to run on much weaker hardware where people will really wait.

    But I first need to run the test again in the original setup cause the attempt to replicate it failed just a few mins ago in the current version of the project as it stands now.
    Question is what could impact it to cause a generation of a collider during the scene loading even if the terrain didn't have one present. Totally in the dark here.

    So for the time being I will have to take back what I mentioned (I only use the profiler on specific situations as it impacts the behavior on its own especially as we are loading quite a bit through WWW after the scene init too), should I be able to replicate it again I will report a proper bug including project, in the hope its not just cause by some data error or whatever.
     
  6. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    Yeah, then just drop the case number.
    We're deep in release mode - so noone have enough time to just look at any problem someone might encounter without proper repro
     
  7. ThomHurks

    ThomHurks

    Joined:
    Jul 27, 2010
    Posts:
    22
    Okay, I managed to figure out the problem more:

    The object has multiple children (4) with box colliders on them, to correctly follow the shape of the object.
    When I deleted all child colliders, and created just one collider on the parent object, I got no more warnings about static collider.move's and collider.creates!

    However, having colliders on children of a rigidbody should be perfectly possbible. It's just a compound collider.
    I have to say though, not all colliders of the object hit all other colliders. Is something going wrong with the compound collider creation?

    Will investigate more.

    edit:

    I reverted to my version of the object with the 4 child colliders, but instead of having a rigidbody on the parent, I created a kinematic rigidbody on each of the child colliders instead. I still had a rigidbody on the parent as well. This fixed my issue!

    If I removed the parent rigidbody, so had only rigidbodies on the children, the problem was still there. I did hear that having rigidbodies on both a parent and its children isn't smart to do. Is that true? Else I'll use the current solution as a workaround.

    So, it seems having a kinematic rigidbody with multiple child box colliders and moving that object around (by changing Transform position) goes totally wrong. It will just create static colliders. This seems to be a big bug. Can anyone duplicate it?
     
    Last edited: Jan 27, 2011
  8. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    Whatever you find (apart from "argh-i'm-stupid" kind of errors ;-)) - please file a bug case *with repro project* and drop me the case number
     
  9. ThomHurks

    ThomHurks

    Joined:
    Jul 27, 2010
    Posts:
    22
    Case nr is 389869, thanks!
     
  10. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,624
    Ok, while we are working on the proper fix here is the workaround for situations where you have RigidBody on parent and colliders on Children.
    All thanks goes to ThomHurks himself!
    deactivate only children objects. While this have some limitations - in most cases you'll be good to go
     
  11. bbvrdev

    bbvrdev

    Joined:
    Aug 11, 2009
    Posts:
    221
    I am having a similar problem, although I have no rigid bodies on either the parent or child objects, only box and sphere colliders. According to the profiler it seems that there is a static collider being created, and I suspect it's messing up my performance.

    Is there any workaround for this situation that doesn't include rigidbodies?
    I am using the 3.4.2f1 beta, but I've had this problem since before this version.
     
  12. XeviaN360

    XeviaN360

    Joined:
    Jun 3, 2010
    Posts:
    181
    I have the same problem. Many objects with colliders, not marked ad Static, no rigidbodies, but when i move them i see in the profiler that line "Static Collider.Move (expensive delayed cost)"
    Why?
     
  13. bbvrdev

    bbvrdev

    Joined:
    Aug 11, 2009
    Posts:
    221
    Colliders on gameobjects with no rigidbody are considered static.