Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Our response to Improbable’s blog post (and why you can keep working on your SpatialOS game). Read more here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

"kinematic bodies with CCD enabled are not supported!"

Discussion in 'Physics' started by dgoyette, Dec 15, 2018.

  1. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,031
    Did this really need to be treated as an error, rather than a warning? Maybe there's some really good reason to avoid this case, but per the error message it seems that PhysX is just going to fallback and use Discrete collisions in this case. So, it feels more like a warning than an error.

    After updating to 2018.3, I'm getting this a lot because of causes where I temporary set a Rigidbody to isKinematic = true. Now it seems that if I ever want to toggle isKinematic, I'll also need to change the collision detection mode, and remember what it was before I changed it. This seems like an unnecessary hassle if PhysX is just going to not really care anyway.

    Anyway, is it possible for Unity to treat this as a warning instead of an error? Maybe that doesn't seem to matter, but with this treated as an error it causes unit tests to fail if this condition occurs.
     
    SparrowsNest and Edy like this.
  2. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,293
    I don't think it should even be a warning. If the kinematic rb still works as expected then this situation should be simply ignored. The manual should just state that CCD does nothing in kinematic rigidbodies. There are also other situations where CCD doesn't have effect.
     
    SparrowsNest likes this.
  3. garrettstamand

    garrettstamand

    Joined:
    Nov 25, 2017
    Posts:
    4
    Is there a way to find out which rigidbody is violating this rule? I really don't mind changing to/from kinematic and changing collision detection via code but I have absolutely no idea what game object (or is it a prefab?) is bringing up this error.
     
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,293
    Clicking the error line in the Console should take you to the offending gameobject. If it doesn't then it's a bug.
     
  5. hartjoshua

    hartjoshua

    Joined:
    Mar 3, 2018
    Posts:
    1
    Seeing this bug, can someone assist me in getting this reported/solved so that I can test my build?
     
  6. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,031
    Don't really count on it being a bug. You can fix this in two ways:
    • If you have any rigidbodies in your scenes, make sure their Collision Detection Mode is set to Discrete, or I think Continuous Speculative is also okay.
    • If you're setting a rigidbody to kinematic in code, first change its collision detection mode or you'll get this error at runtime.
     
    xVergilx likes this.
  7. Vamireh

    Vamireh

    Joined:
    Oct 10, 2017
    Posts:
    2
    I have Collision Detection Mode is Discrete
    But still get this issue
     
  8. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    1,031
    Are you changing isKinematic in code? Or are you seeing this in the console while in the Unity editor? Most likely there's just a rigidbody you've overlooked.
     
  9. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,173
    The issue probably has something to do with Contact Pairs Mode. Since it can't very well do speculative contacts otherwise, so the warning is likely before this functionality was added.

    @yant or @MelvMay could provide insight if not too busy :)
     
  10. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    20
    My opinion is same as OP.
    Setting/unsetting IsKinematic should not give you any error or even a warning.
     
    Edy likes this.
  11. smonchdev0

    smonchdev0

    Joined:
    Sep 25, 2018
    Posts:
    5
    I have the same issue with 2018.3.0f2 when I load certain scenes that contain Rigidbodies. I've checked the Rigidbodies two different ways and none of them should trigger this error.

    First searching via the Hierarchy with t:rigidbody and then manually checking each result.

    Then with editor code that roughly looks like this... and although they're not shown here, I sanity checked and listed the opposite results as well.

    Code (CSharp):
    1. [MenuItem("Tools/Count Rigidbodies")]
    2. static void CountRigidbodies()
    3. {
    4.     var result = GameObject
    5.         .FindObjectsOfType<Rigidbody>()
    6.         .Where(body => body.collisionDetectionMode != CollisionDetectionMode.Discrete)
    7.         .Count();
    8.  
    9.     Debug.Log($"Count: {result}");
    10. }
    It'd be nice if the editor would provide any information at all about the offending objects, especially since they don't appear to be easy to find. This looks like a bug to me, but am hoping someone may have more information or perhaps a quick workaround. Thanks!
     
  12. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    24,173
    Has anyone got a bug report number I can highlight for Unity to peep at? they would love to see it...
     
  13. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    34
    I get this frequently on 2018.3, good to know its nothing serious haha. Does anybody know the reason its not supported, out of curiousity?
     
  14. smonchdev0

    smonchdev0

    Joined:
    Sep 25, 2018
    Posts:
    5
    Thanks! I just filed a new report. There's no link yet, but here's the info... title's cut off:
    (Case 1115155) Can't build due to erroneous error: "kinematic bodies with CCD enabled are not supported

    And this is what's in it...

    Description:

    Builds are failing due to the following error:
    [Physics.PhysX] RigidBody::setRigidBodyFlag: kinematic bodies with CCD enabled are not supported! CCD will be ignored.

    The error is also triggered both when loading a scene in the Editor and when loading in Play Mode.
    Some scenes trigger this error and some don't. Those that do, always do, and those that don't, never do.

    I've ensured that all kinematic Rigidbodies in a given scene are using discrete collision detection and no interpolation.
    I've searched for Rigidbodies using the following two methods:

    1. Searching via the Hierarchy with t:rigidbody as the query and then manually checking each result.
    2. Using editor code similar to this:

    var result = GameObject
    .FindObjectsOfType<Rigidbody>()
    .Where(body => body.collisionDetectionMode != CollisionDetectionMode.Discrete)
    .Count();

    Searching the forums, it's fairly obvious that I'm not the only one encountering this issue.
    Also, there is a similar bug report indicating that a fix may be one the way, but that report's scope is limited to Play Mode.

    Steps To Repro:

    Unfortunately, I have no idea how to recreate this situation. For what it's worth, my project has been upgraded across multiple versions of Unity. The last two versions were 2018.2 and 2017.4.
    2018.3 is the first build in which I've encountered this situation.

    Expected Results:

    At minimum, the project needs to build without failing over something that looks more like a warning than an error. But it really looks like it shouldn't be getting triggered in the first place.

    Thanks in advance! Really need to get builds out to multiple platforms ASAP. A quick patch release would be great if possible!
     
    Squize and Hagen like this.
  15. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,293
    By definition kinematic rigidbodies don't react to collisions themselves, to start with. Position and rotation are entirely script driven. If you move a kinematic rigidbody from A to B (via Rigidbody.MovePosition) then at the end of the frame it will be at B no matter all other rigidbodies and colliders present in the scene. Only visual interpolation will be applied if enabled.
     
    Subliminum likes this.
  16. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,293
    So if a kinematic rigidbody has CCD also enabled, it should silently keep acting as a kinematic rigidbody. No warning nor error make sense here. Once the kinematic flag is cleared, then the rb could start acting as a regular physics-driven rigibdody applying CCD and all other options.
     
    Subliminum and Rohirm like this.
  17. smonchdev0

    smonchdev0

    Joined:
    Sep 25, 2018
    Posts:
    5
    Problem solved!!! But it still looks like a bug. Turns out I had instances of a problematic prefab being used in several scenes. I think I manually overrode it in all the scenes as I was transitioning to Unity 2018.3 and trying to fix a huge volume of compiler warnings and errors involved with virtually any major Unity upgrade. Unity complained about the CCD issue and I removed the Rigidbody because it wasn't actually even being used at this point. Would've made sense to hit it from the prefab level, but that didn't happen... until just now. In any case, it looks like Unity is complaining about what it sees at the prefab level regardless of whether or not an instance has been overridden to correct a situation. So that's why I didn't find the issue with the methods I mentioned above.
     
    Subliminum likes this.
  18. Subliminum

    Subliminum

    Joined:
    Nov 9, 2017
    Posts:
    34
    Don't they still use that information for collision detection even when kinematic? I'm wondering since an Asset im using specifically tells you to have CCD and kinematic enabled for melee weapons. I assumed this was because collision detection or triggering would be more accurate in this mode as opposed to discrete.
     
  19. smonchdev0

    smonchdev0

    Joined:
    Sep 25, 2018
    Posts:
    5
    The way I understand it and please correct me if I'm wrong... kinematic bodies operate roughly the same as non-kinematic bodies when it comes to collision detection. My guess is that the engine would see them hopping through space like regular discrete bodies with maybe a slightly wobbly velocity (calculated via distance traveled) from one step to the next. Interactions have to be handled manually from the perspective of a kinematic body, but from the perspective of other others, it should be about the same. If the hop is too extreme, then you'd get tunneling and it'd seem like things aren't working. I'm not sure why CCD wouldn't be possible other than maybe it's too clunky with a wobbly velocity? FWIW I'm guessing about that... haven't tested it. Maybe the reason speculative collision detection is ok, is because it's roughly the same as discrete except that the bounding boxes are padded per step in a speculative manner.
     
    Subliminum likes this.