- Home /
This question was
closed May 28, 2019 at 07:52 AM by
Darioszka for the following reason:
Solved
Question by
Darioszka · May 27, 2019 at 08:22 PM ·
collisioncolliderscollision detectioncollision2dpoint
Collision point problem
Hi I would like to check vector2d for collision point. In 2018 my code is working good:
void OnCollisionEnter2D (Collision2D col)
{
print("First point that collided: " + col.GetContact(0).point);
}
but when I export my project to Unity 2017 this code is not working. There is a bug: IndexOutOfRangeException: Array index is out of range. and I dont know why.
How can I check collision2d point in Unity 2017?
Comment
This sounds like a bug, I would send a bug report. "Help / Report a Bug..." If the collision is happening, there has to be at least one contact so the index at position "0" should definitely return the contact.
Best Answer
Answer by Darioszka · May 28, 2019 at 07:51 AM
Thank you This works:
print("First point that collided: " + col.contacts[0].point);
with using System;
ya, using directives are important. $$anonymous$$ark your answer as correct to resolve it