Hello, I am attempting to get all the collisions with the sphere in the picture in order to get the mean normal. Because I am checking in the collection other.contacts, the length of the contacts array is always 1, because it is checking the one wall to see what is colliding with it, which is only my one sphere. I want to check everything that is colliding with the sphere, i.e. the two walls. Is there a way to do from a single OnCollisionStay2D call? In other words, get all collisions on this gameobject, not the other colliding object. The following code always logs “NumContacts: 1, Normal: (the normal of the longer wall)”. Thanks.
void OnCollisionStay2D(Collision2D other)
{
Vector2 vecNormal = Vector2.zero;
foreach (ContactPoint2D contact in other.contacts)
{
vecNormal += contact.normal;
}
vecNormal /= other.contacts.Length;
jumpNormal = vecNormal;
Debug.Log("NumContacts: " + other.contacts.Length + ", Normal: " + jumpNormal);
}