How to get contact point between two objects in unity 2017?

private void OnCollisionEnter2D(Collision2D t)
{
Instantiate(PsBlood, t.contacts[0].point , Quaternion.identity);
}

This Code used to work in unity 5
but in unity 2017 its not working

It shows me this error:

IndexOutOfRangeException: Array index is out of range.
PRF.OnCollisionEnter2D (UnityEngine.Collision2D t)
I know this is due to

t.contacts[0].point

I tried this code below to get contact points but still not working

ContactPoint2D[] contacts = new ContactPoint2D[10];
t.GetContacts(contacts);

Please Help ASAP

The latter approach with GetContacts is definitely the way to go, but you should cache ‘contacts’ as a class member and just re-use the same 10-element array each time you use GetContacts, without recreating it (make it static, even)- that’s how the function is designed. GetContacts also returns an integer that says how many contact results were found, so you should use that to make sure 1 or more was, and react appropriately.

As for not having any contacts in the array, I’ve never seen a problem like that in OnCollisionEnter2D, even in 2017 (though LOTS of people had the problem with OnCollisionExit2D- there isn’t a point of contact if the collision is exiting, obviously). It sounds like a bug, and there were contacts-related bugfixes in 2017.2.0p3 and 2017.2.0p4 (though neither sound exactly like this, they may be related), so I would try grabbing p4 and checking it out there to see if that fixes the issue.

If none of that solves your issue, you may want to test out 2017.3 instead- one of the things updated with it involved physics contacts, listed as follows:

Physics: Exposed new settings in the
Physics Manager: Contacts Generation,
Contact Pairs, and Broadphase Type.
This allows receiving the collision
and trigger events from
kinematic-kinematic and
kinematic-static contact pairs.

Again, not exactly a definite solution, but each time they mess with the physics system they end up breaking something, so maybe one of these times they fixed this issue. Hope some of that helps. Good luck!

I have Solved The problem

The problem was this

I have two gameObjects with Rigidbody2D and BoxCollider2D added.

In the first gameObject I have this code:

  private void OnCollisionEnter2D(Collision2D t)
 {
   Instantiate(PsBlood, t.contacts[0].point , Quaternion.identity);
 }

In the second gameObject I have this

  private void OnCollisionEnter2D(Collision2D t)
 {
                Destroy(GetComponent<Collider2D>());
 }

Because I am destroying the Collider2D in the second gameObject, the first gameObject cant find any contact points

Thanks to @Lysander and @pako for involving and discussing