- Home /
OnCollisionStay2D - why is the list of contacts is incomplete?
Hey all,
Here is my code:
void OnCollisionStay2D (Collision2D col) {
for (int i = 0; i < col.contacts.Length; i++) {
... blah blah ...
Debug.DrawRay(p1,a1,Color.white);
print ("Ima colliding");
}
}
Okay, so here is the thing, I have the above code on an object complete with collider2d and rigidbody2d. Everything works, except that the object doesn't return all contacts. Sometimes OnCollisionStay stops firing even when the object is in contact with another (like, its sitting on it). Between other dynamic objects, On collision stay doesn't always return.
Between a sphere and an edge object, only one cantacting edge usually gets reported. So if you have a ball that falls down a v shape edge, it wil report only one contact but will jitter and say there is 2, but not always.
I was hoping to be able to go through the list of contacts and look at normal information to determine wether an object is on the ground/wall/ceiling etc. But OnCollisionStay is inconsistent seemingly. The contacts returned are incomplete usually. In the v example, the ball could be sitting on the ground with a slight slope leading to the wall. gravity can pull the ball to the wall, but OnCollisionStay still only reports one contact. Sometimes the wall, sometimes the floor, sometimes, neither.
Any insights?
I was hoping as I said to check the objects relative whereabouts but it seems I'll have to screw around with a bunch of boxcasts. I don't get it. Iv'e used box2d before in a variety of settings and I know its not broken.
Your answer
Follow this Question
Related Questions
How to get rid of jumpy collisions? 1 Answer
Obtaining Collision Information (contact points, etc.) WITHOUT affecting physics 4 Answers
Mesh Colliders and 2D Colliders 1 Answer
other.contacts[0].normal changes over time 0 Answers
How do I solve the Box Collider (3D) Edge / Corner Collisions problem? 5 Answers