- Home /
The question is answered, right answer was accepted
collision.contacts never has more than 1 element
I'm making a 2D game and need to dot the contact normals of all the points of contact when my player is getting smushed. When I use the scripting example to draw the contact normals in OnCollisionStay, I see two normals as I expected. In the same chunk of code I put in print(collision.contacts.Length) and it is always 1 (even when debug draw shows 2 contact normals). This one's got me scratching my head. My best guess is that they're being processed one after the other or something like that. Is there another way I can do this to have access to both contacts at the same time? Thanks in advanced for the help.
has anybody been able to figure this out, it's killing me
Answer by Eno-Khaon · Mar 21, 2016 at 08:02 PM
If I'm not mistaken, I would presume that contacts would be on a per-object basis.
If you are making contact with two separate objects at one point on each, you would have two single-element arrays. If you're contacting a single object in multiple locations (such as nestled in a crevice in a concave collider), then you would have multiple points of contact on a single object, resulting in a multi-element array for that object.
Yea, either that or on collision basis. i solved my problem by storing all the contacts in an array that gets cleared on every fixed update. It's not perfect but it worked . Thanks!