Question by
Wenon · Mar 18, 2018 at 10:32 AM ·
collisionunity 2dcontact.point
C# ContactPoint2D and Array index is out of range
Hello, english is not my native language so sorry for any mistakes. I have a problem with one think. I want to take contact point when ball hits block. It works with almost every clones of block but with some clones error apperas "Array index is out of range" and this is about this line: ContactPoint2D contactpoint = collision.contacts[0]; I dont know why, all clones of block are the same. Please help.
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "block")
{
ContactPoint2D contactpoint = collision.contacts[0];
contactX = contactpoint.point.x;
contactY = contactpoint.point.y;
}
}
Comment
Your answer
