How I properly use Collision.GetContacts()?

Docs say don’t use Collision.contacts, to use .GetContacts, but doesn’t provide an example. The stuff I found in the forums that uses .GetContacts still pulls from Collision contacts via foreach.

How I properly use Collision.GetContacts()?

You basically have to make an array to store the contacts and to get the contacts you need to use OnCollisionStay or OnCollisionStay. Like this.

private ContactPoint2D[] contacts;

private void OnCollisionStay2D(Collision2D collision)
    {
        contacts = collision.contacts;
    }