Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Do 2D triggers pass through each other with continuous collision detection without OnTriggerEnter?

Discussion in 'Physics' started by Raveler, Jul 15, 2016.

  1. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    I believe that continuous collision detection is broken in at least Unity 5.3.5. Even if it's on, the objects still pass through continuous collision detection is on. It happens when a Rigidbody2D has continuous collision detection and is supposed to hit a normal BoxCollider2D (without a Rigidbody2D). The object will still pass through!

    Anyone else experienced this? Is this normal? The documentation (https://docs.unity3d.com/ScriptReference/CollisionDetectionMode2D.Continuous.html) seems to suggest this is a bug.

    I've attached a quick example showing the problem.
     

    Attached Files:

  2. calebc01

    calebc01

    Joined:
    Jul 21, 2015
    Posts:
    62
    Your object needs a non-kinematic rigid body in order for the physics engine to simulate forces that keep the two objects apart.
     
  3. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    That's the case. It's a non-kinematic Rigidbody2D with a trigger CircleCollider2D attached to it. It should trigger OnTriggerEnter2D() when passing through the object, no?
     
  4. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    You did point me in the right direction though - this only happens with triggers. Maybe continuous collision detection does not work for triggers?
     
  5. calebc01

    calebc01

    Joined:
    Jul 21, 2015
    Posts:
    62
    No, you need a rigidbody on each object. (EDIT: at least, I think this is the case. I'm not at my development machine right now or I'd give it a try)
     
  6. Raveler

    Raveler

    Joined:
    Sep 24, 2012
    Posts:
    40
    You definitely don't if the moving object is not a trigger. Then it just works if the wall is not a rigidbody. So I don't think that's the problem here.
     
  7. calebc01

    calebc01

    Joined:
    Jul 21, 2015
    Posts:
    62
    Got it, that's good to know. You must be right, it's got to be the trigger flag.