Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

OnCollisionEnter2D called once on colliding with 2 objects

Discussion in '2D' started by dumbat, Jun 5, 2014.

  1. dumbat

    dumbat

    Joined:
    Apr 24, 2014
    Posts:
    11
    Hi

    On 4.3.4f1 I have 2 x BoxCollider2D objects which partially overlap. If I throw a ball (a RigidBody2D with CircleCollider2D) so it bounces off both the boxes, I get OnCollisionEnter2D calls as expected. If however I throw the ball so it hits both boxes simultaneously, no OnCollisionEnter2D calls are called for one of the boxes (either in the ball's script or the box's script). The ball still bounces as expected though.

    Has anybody else seen this? If so, did you find a workaround?

    cheers
     
  2. Tourist

    Tourist

    Joined:
    Jan 3, 2013
    Posts:
    10
    It happens to me on version 4.5.0f2 as well but between a circle collider 2D (the ball) and an edge collider 2D. However this problem does not always happen but may happen.
     
  3. Pyrian

    Pyrian

    Joined:
    Mar 27, 2014
    Posts:
    301
  4. hepphep

    hepphep

    Joined:
    Feb 1, 2013
    Posts:
    24
    Keeps happening for me as well on 4.6.0f3. Any idea if this is on the list of known bugs and to be fixed? I have two circle colliders and one box collider and when circle collider hits to other circle collider and box collider, only one of the circle colliders and box collider have theri OnCollisionEnter2D called. However, the collision is taken in account on the physics behavior and the ball (which has one of those circle colliders attached) jumps backwards from collision exactly as if collided with both on same time.

    In addition, I also checked number of contact points given in Collision2D when that happens, and I'm only given one, so it cannot be even dealt with ugly hack to duplicate collision detection for different types of object and cross-checking them.