Search Unity

Collider2D.GetContacts() always returns only 1 contact

Discussion in 'Physics' started by frederic_unity363, Jan 17, 2019.

  1. frederic_unity363

    frederic_unity363

    Joined:
    Nov 26, 2018
    Posts:
    6
    I try to get the contact points of 2 2D Colliders (circle and box) which are moving towards each other and eventually overlap. The Maximum Amount of Contact Points would be 8 then. So I am saving the contacts in an Array but when colliding, but there is always only 1 contact point in the array.

    Code (CSharp):
    1.  
    2. void OnCollisionStay2D(Collision2D collision)
    3.     {
    4.         collision.GetContacts(contacts);
    5.  
    6.         foreach (ContactPoint2D contact in contacts)
    7.         {
    8.             Vector2 hitPoint = contact.point;
    9.             Debug.Log(hitPoint.ToString());
    10.         };
    11. }
     
  2. frederic_unity363

    frederic_unity363

    Joined:
    Nov 26, 2018
    Posts:
    6
    Unfortunately I cannot edit that post. So additional Information here:
    To visualise my problem you can see both shapes in this image. At this point there should be 2 contact points, I assume.



    But my array looks like this: